Home:ALL Converter>Applying translation to custom WordPress plugin

Applying translation to custom WordPress plugin

Ask Time:2017-09-06T21:50:22         Author:Oleg

Json Formatter

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

Author:Oleg,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46077044/applying-translation-to-custom-wordpress-plugin
yy