“I can’t find my string from Polylang’s Translations list” – does that issue ring a bell to you? In this short guide, we explain why some strings are not initially foundable and we give you an easy solution to find them and translate them using the Loco Translate plugin, freely available on wordpress.org.
Why You Need Loco Translate
You need Loco Translate if you can’t find some of your WordPress PHP strings in Polylang Translations table (Languages > Translations). Some strings coming from your theme or a plugin may not be listed, as you can see in the figure below:
If that’s your case, it’s crucial to understand the two types of strings that exist in the translation jargon on WordPress.
The Two Types of Content Strings
In your WordPress site, you can find two types of strings:
- The strings coming from the theme and plugin dynamic options (they are the strings that you enter in the backend). In Polylang, they appear directly in the WordPress admin in the Translations panel (Languages > Translations). The strings appear automatically for themes and plugins that have decided to be multilingual-ready.
- The strings coming from WordPress, the theme, or the plugins that are located in the .po /.mo files. Those are not scanned by Polylang and will not appear in the Translations panel, but they are translatable using Loco Translate.
Why Are Some of My Strings Missing in the Translations list table?
That’s because the string you may want to translate is a hardcoded string and the Translations list table is dedicated to the dynamic options. It does not handle the hardcoded strings in PHP files. In other words, these strings from the PHP files of your theme and your plugins are not translatable by Polylang. To translate them you need to use another tool: Loco Translate.
Where Are The “Missing” PHP Strings?
These PHP text strings coming from the theme or the plugin are stored in .po/.mo files and you will need a separate plugin like Loco Translate to translate them. Once your translations are done with Loco Translate, then Polylang will simply load these new translations when necessary.
Important:
⚠️The translation will be possible only if the theme and plugins are internationalized – meaning – ready to be translated. Popular themes like Astra or Divi, are more likely to be localized than a brand new theme recently launched on the market. |
Polylang and Loco Translate: Full Tutorial
Polylang and Loco translate are complementary because they allow you to translate different types of content.
About Loco Translate
The Loco translate plugin is very efficient for localizing WordPress themes and plugins. Loco Translate is a plugin available on the WordPress repository that allows the user to edit translation files, such as themes or plugins. The main features include:
- PO editor within WordPress admin (so you can work directly from your dashboard)
- Create and update language files directly in your plugin or theme
- Full extraction of translatable strings
- MO files compilation
- PO file backup
- Integration with translation APIs including DeepL, Google, Microsoft, and Lecto AI
- Comes with built-in WordPress locale codes
Installing Loco Translate
From your WordPress dashboard, go to Plugins > Add new > Loco Translate and click on the “Install Now” button.
A new section “Loco Translate” in the main menu is created:
Loco Translate immediately recognizes the languages installed on my website:
– English (US) which is my site language (✓)
– English (NZ)
– Spanish (Spain)
– French (France)
Translating A Theme with Loco Translate
Navigate to Loco Translate > Themes and click on the one you are currently using (it’s Astra, in our case):
Now it’s time to see how to translate hardcoded strings with Loco Translate. We will give an example with the Astra theme (containing a placeholder), but before digging into the details, let’s have a quick overview of Loco Translate.
Overview of Loco Translate
This is what the interface looks like, as you can see it’s pretty straightforward to edit an existing translation.
As you can notice, there are two main sections involved with Loco Translate:
- The upper section “Source Text” that contains the English Strings (or original language)
- The translation section (French translation) where you add your own String translation
Creating a new translation for Astra Theme With Loco Translate
If there is no translation in one of the specific languages of your site, then you create this translation yourself with Loco Translate by following the steps below.
- Go to Loco Translate > Themes and click on the New language button:
- Choose your language, choose a location (System) and press the Start translating button:
- Use the search form to find your string (bullet 1). Then click on the string to select it (bullet 2). Translate it to French (bullet 3). Finally, press the ‘Start translating‘ blue button (bullet 4).
On the front end, the new translation should be displayed.
💡What about the strings with placeholders?
→ Keep the placeholders in the translation as shown in the example above |
Location of The Translation Files
When you start translating your theme or plugin into a new language, you have to choose where to put the translation files. In the previous section, we have seen that there were three possible locations for your translation file: Custom, System, and Author.
While we recommend using the System location, let’s go over the three of them in detail.
Custom directory => You can put your custom translations in this directory to protect them from an update. In this file, custom translations will not be overwritten when the theme gets an update. However, keep in mind that this directory is not compatible with the Polylang option “The language is set from the content”.
Author directory => Don’t put custom translations here because they will be deleted at the next theme update.
✅System directory => We recommend putting your custom translations in this directory. They will benefit from community or professional translations if they are available on the official WordPress translation for themes and extensions that are on wordpress.org. Once the “official” translation will be published, the custom translation will be replaced by the official one coming from the theme or plugin authors.
What about the premium themes or plugins? There is no problem to put the custom translation in this file either because they will never be updated by the authors there. (Paid themes and plugins are not on wordpress.org.)
Translating A Plugin with Loco Translate
Simply go to Loco Translate > Plugins and follow the same previous steps we highlighted for the theme translation.
And that’s it!
Polylang and Loco Translate are not competitors, they are mutually beneficial. When using them together, you make sure that each part of your WordPress site gets translated properly, including the hardcoded PHP strings.