Using translation plugins (like Loco Translate)
I generally recommend using Loco Translate with its addon Automatic Translate to automatically translate string (over 80% translations are ok, while 20% may require manual corrections).
Rey theme is mostly a skeleton, while Rey Core actually extends it with features. So most text strings will be located in Rey Core plugin.
Make sure to scan for text strings in:
- WooCommerce
- Rey Core plugin (everything WooCommerce related)
- Rey Theme (generic blogging strings)
Here’s a quick video of Loco Translate in action https://d.pr/v/orftUN .
Troubleshoot: translations are overwritten/lost on updates
Make sure to check where the translation files are saved to avoid them being overwritten by updates. More here https://localise.biz/wordpress/plugin/manual/msginit#locations . Basically “Custom” is the recommended choice.
Troubleshoot: some text strings don’t show up after searching
This might be happening because the text string you searched for is added after the last translation process, meaning that the language files are not updated in Loco Translate. Simply try to click on the Sync button eg: https://d.pr/i/U9R6S2 and retry searching afterwards.
Using multilanguage plugins
Rey supports multiple translation plugins such as Polylang, WPML, Gtranslate or QTranslateX (deprecated). If you install any of these plugins, you should be able to find a new “Language switcher” element added to the elements tray in Elementor editor.
Using code snippets
For some reason if you want to use plain code to change texts, here’s how you can do it:
add_filter('gettext', function ($translation, $text, $domain) {
if( $domain === 'rey-core' ){
$translation = str_replace('Some Text', 'Translated text', $translation);
}
return $translation;
}, 10, 3);
Some texts are registered with a context, therefore this code is more appropiate.
add_filter('gettext_with_context', function ($translation, $text, $context, $domain) {
if( $domain === 'rey-core' ){
$translation = str_replace('Some Text', 'Translated text', $translation);
}
return $translation;
}, 10, 4);
In both examples you can see i’m limiting to “rey-core” text strings only. You can also use “rey” if a text comes from the theme.
3 Replies to “Translating Rey theme and Core plugin”
Julien Deret
The auto translate plugin is dead .The free IBM api doesn’t work and the Yandex API isn’t free anymore. Any alternative ?
Julien Deret
No need to publish. They published today a fix for that.
mariushoria[ Post Author ]
Hey Julien,
Not sure what you meant with “free IBM api”. To be honest i’m also interested in an alternative solution to Yandex API which isn’t free anymore. I had noted to find automatic translation solutions too. Thanks!