How to translate themes
In this guide, we will explain how to translate themes using Polylang plugin.
- Download and install Polylang plugin
- Adding languages
- Translate posts/pages
- Translate built-in sections of the theme
- Translate Menus
- Translate Widgets
- Translate non-dynamic strings
- The Child Theme case
- Show/hide section based on the language, in Hestia Pro
1. Download and install Polylang plugin
2. Adding languages
Now that the plugin is installed, let's configure the desired languages.
Dashboard->Languages->Languages, Add new.
After adding all of them, make sure that there is at least one post created in each language -- if you don't know how to add a new post in a certain language check step 3.
From this page, a default language can be set for all posts that were on the site before installing Polylang plugin.
3. Translate posts/pages
Posts can be translated in Dashboard->Posts. Just localize the desired post and click the plus sign corresponding to the desired language next to the post name.
This way a new post was created with the same attributes, so you just need to add the content here.
The post language can be also set while editing it. Also, the correspondent of the post in other languages will be visible in the sidebar while editing the post.
The same steps can be followed for translating pages.
4. Translate theme built-in sections/front page
The steps in this section apply to the following ThemeIsle themes: Hestia Pro, Zelle Pro, ShopIsle Pro. The same approach should work for translating the Customizer strings of any theme.
The following themes, Hestia Pro, Zelle Pro, ShopIsle Pro have front page sections that can be edited only from the customizer(Dashboard->Appearance->Customize). Therefore, you can't create a new page as you would do for regular pages.
All those strings can be translated in Dashboard->Languages->Strings translations. If a particular string doesn't appear there, you can try modifying it and save changes within the customizer.
Image set in the customizer can be also translated here by setting a different image URL for a different language. Such an image URL can be found in Dashboard->Media Library.
The same approach can be used to translate a contact form. Just create a new one for a different language and translate the shortcode.
In case the front page of the theme works with the Static Page option, make sure to choose a page who exists in all languages, as the front page.
Hestia Pro works like that.
5. Translate menus
Menus can be translated in Dashboard->Appearance->Menus.
You can create a different menu for another language or use the same on all languages. If the theme you are using is compatible with Polylang plugin, each menu location will appear at least twice, depending on the number of languages that you have configured on your site.
Adding language switcher to the menu
In order to add a language switcher to the menu, you have to enable it from the screen options, add it to the menu and configure how it should work(as a drop-down, displaying language name or just flags).
6. Translate widgets
7. Translate non-dynamic strings
A non-dynamic string is one that can't be edited with the theme settings.
For more information, please check this guide.
8. The Child Theme case
If you are using a child theme, like Orfeo Pro which is a child theme of Hestia Pro, an additional step might be required.
Copy the wpml-config.xml file from the parent theme folder(in this case Hestia Pro) into the child theme folder(in this case Orfeo Pro).
At the beginning of the file, you will see a line similar to the following one
Change the theme name, with the child theme name. This one can be found in the style.css file of the child theme. Use the words next to the Theme Name entry, with lowercase and dash between the words.
That's it! All of the steps presented in this guide should now work for the child theme as well.
9. Show/hide section based on the language, in Hestia Pro
In Hestia Pro, the front page sections can be shown or hidden from the option available in the Customizer, example below.
It is possible to translate this option, by creating a child theme. You can download it from here, and install it as a new theme.
In case you are already using one, please add this file to the child theme folder.
After that, you can translate the value of the show/hide option, as follows.
- 1 - means true
- 0 - means false
It depends on how did you set the control, basically, if the section is enabled on the default language, you can add 1 in the translation to hide it on the other languages.