1
votes

I'm trying to apply a translation to my cusom plugin. I've alredy created brau-ru_RU.mo and brau-ru_RU.po files. My translation domain is 'brau'.

What I've tried is to put files in wp-content/languages/plugins/ and execute this code in my plugin.

$domain = 'brau';
$mo_file = WP_LANG_DIR.'/plugins/'.$domain.'-'.get_locale(). '.mo';

var_dump(load_textdomain( $domain, $mo_file )); 
var_dump(load_plugin_textdomain( $domain ));
var_dump(__('This is the test', 'brau'));

Result is:

bool(true) bool(true) string(16) "This is the test"

I also got this code in my config

define ('WPLANG', 'ru_RU');

The text shoud be translated from English to Russian, but it's not. What am I missing?

This is a link to test version of the plugin: https://github.com/Brezgalov/brezgalovauth

1
is your get_locale() returning ru_RU?Stender
and is the path correct, if you var_dump($mo_file);Stender
Yes, get_locale and $mo_file is ok, just checked it twiceOleg

1 Answers

0
votes

If you want to add language files to your plugin then you can create a folder called languages inside your plugin folder and in the plugin main file you can define like this

// Localiztion with language files
function custom_langs_i18n() {
    load_plugin_textdomain( 'textdomain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'custom_langs_i18n' );

Please remember to use textdomain where you are using string.