I have in my php files string like this:
<?php
__('My string A', 'a_theme');
_e('My string B', 'a_theme');
?>
and there are not appearing in "String translation" .
I have also bought and installed this theme: http://preview.ait-themes.com/index.php?bartype=desktop&theme=touroperator and strings from that theme aren't also appearing in "Strings translation" of WPML.
This is one example of string which was already in theme when I installed it:
<input type="text" id="dir-searchinput-location" class="dir-searchinput-select" placeholder="{__ 'Destination'}">
Is there some extra configuration which I need to do or something else?
Thanks for help
To get strings to appear in String Translation, you first need to go to Theme and plugins localization. Scroll down to the Strings in the theme section and then click the Scan the theme for strings button. WPML will then detect any unregistered or newly added strings that are properly formatted for localization.
If it works, you'll see your theme a-theme
listed in the Domain column and the number of detected strings in the Count column. Clicking the View strings that need translation button will take you to String Translation. If any of the strings aren't properly formatted for localization, the count won't be updated.
If you update existing strings or add new ones, you'll need to rescan before WPML adds them to String Translation.
The formatting in your first example looks OK and WPML should detect the strings, but in the second example, you haven't declared a domain. Without a domain, WPML won't pick up the string.
The correct format is
__('Your string', 'yourDomain')
or
_e('Your string', 'yourDomain')
In this case, the domain should be the name of your theme, 'a_theme'
.
Those strings are cached somehow. So, if you added new one (the right way) and it still doesn't appear in String translation go to "Theme and plugin localization" and hit "Scan the theme for strings" button. This will re-index strings and your newly added one should appear (worked for me).
I have same problem, my theme is "bookyourtravel", and plugin "WPML string translation",did not translate these texts:
<?php _e('Accommodations', 'bookyourtravel'); ?>
<?php _e('Tour', 'bookyourtravel'); ?>
<?php _e('Accommodation', 'bookyourtravel'); ?>
No translated!!!
My solution was:
- In WPML go to "localization of themes and plugins", check in
Translated by WPML, then clic en Save.
- Now in, "Translated string", clic in button: save the settings and rescan strings.
If you use Cache, then Clear all cache in pages.
ready, this worked!!!!!!!
source : https://wpml.org/forums/topic/using-gettext-for-hard-coded-strings-what-else/