Translating Rey theme and Core plugin

You are here:
Estimated reading time: 1 min

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 .

Note: 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.

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.

Was this article helpful?
Dislike 1
Views: 1754

3 Replies to “Translating Rey theme and Core plugin”

  1. 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 ?

    1. Julien Deret

      No need to publish. They published today a fix for that.

      1. 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!

Leave a Reply to mariushoria Cancel reply