Can’t find strings you’re looking to translate on the String Translation page? Here, we’ll go through some common reasons why, and where you can find them.
On This Page:
|Why can’t I find my strings?||Solutions|
|Theme or plugin translation files have changed|
|Strings aren’t selected for translation|
|You still can’t find the strings and need advanced String Translation tools|
|Translations aren’t synced across all your servers|
Themes and plugins usually come with their own translations for the texts you can find in their user interface as well as their front-end output. They store these translations inside translation files.
By default, WPML doesn’t scan or load these translation files into the database. Because of this, you will not be able to find these strings on the String Translation page.
If you want to translate or edit these strings, you first need to scan the translation files of the related theme or a plugin.
- Go to WPML → String Translation.
- Try searching for the string, and a drop down called Can’t find the strings you’re looking to translate? will appear. Expand it. Under Some of the translations have changed, choose the theme or plugins you would like WPML to scan. Then click Scan translation files.
- After the scan is complete, the page refreshes, and you can now select the related theme or plugin in the Select string within domain dropdown.
Some themes or plugins have hard-coded strings wrapped in a gettext function. String Translation only scans the MO files for translatable strings so any hard-coded strings will be missed.
To scan for hard-coded strings:
- Go to WPML → Theme and Plugins Localization.
- Select the theme or plugin and click to scan it.
- After the scan is done, you should be able to find the strings on the String Translation page.
Many themes and plugins store texts in the wp_options table. These strings first need to be registered as translatable and added to String Translation.
To register these strings:
- Go to WPML → String Translation.
- Try searching for the string, and a dropdown appears called Can’t find the strings you’re looking to translate? Expand the dropdown and click Choose texts for translation.
- If you don’t see the dropdown, scroll to the bottom of the page and click the Translate texts in admin screens link.
- This will take you to a searchable list of admin strings. Select your string and click Add to String Translation. Then, translate your string as normal on the String Translation page.
- Alternatively, you can click Export as a WPML configuration file to generate a code snippet to use in your language configuration file.
If you still can’t find your strings, WPML has tools that can help you locate them. You can access these from WPML → String Translation.
This option helps you identify where strings are used on public pages in the site. When enabled, WPML will keep a record of the PHP source and pages that display each string. This feature can help understand the correct context of strings and how they should be translated.
How to use:
- Enable the Track where strings appear on the site option.
- Visit the site’s front-end pages.
- Switch to a language other than the site’s default language.
- WPML will register any string that appears on the page you are viewing. Move from page to page to cover all the strings you need.
Please note that this is a database-intense operation. You should only enable it when building the site. When you are done registering strings, don’t forget to return to the String Translation admin page and disable Track where strings appear on the site. Your site’s speed will be significantly lower if you keep this option running in production mode.
WPML uses static code analysis to locate strings that require translation in the theme and plugins. In some cases, the static code-scan cannot reliably find all strings. This often happens when strings are generated dynamically using code.
By enabling auto-registration, WPML will register strings from all text domains that need translation at display-time. The conservative option is to register strings when logged in as an administrator. This means that when a logged-in admin browses the site, WPML registers for translation any strings that are displayed.
This operation may increase a number of database queries while strings are registering for translation.
As a default, String Translation only stores MO files on one server. This means that if your site runs on multiple servers, all the requests handled by other servers do not translate the strings.
As of WPML 4.4.0, you can enable a custom mode to synchronize your MO files across your servers. To do so, add the following to your wp-config file:
define( 'WPML_ST_SYNC_TRANSLATION_FILES', true );
Please note: This synchronization mode will add another layer of logic that may affect your site’s performance. We recommend using it only if required.