I have problem with loading internationalization in my admin page. For generating .po and .mo files i use Poedit.
My plugin structure is simple:
├───plugins
│ └───radni
│ └───radni.php
│ └───lang
│ └───radni-sr_RS.mo
│ └───radni-sr_RS.po
Plugin header:
/**
* Plugin Name: Radni
*
* Text Domain: radni
* Domain Path: /lang/
*/
Load hooks:
add_action( 'init', 'myplugin_init' );
Also i try hook 'plugins_loaded'
Then callback
function myplugin_init()
{
load_plugin_textdomain( 'radni', false, dirname( plugin_basename( __FILE__ ) ) . '/lang');
}
And set in wp-config.php
define('WPLANG', 'sr_RS');
I use __('','') and _e('','') but nothing is translated.
I try to make debug:
function my_i18n_debug(){
$loaded=load_plugin_textdomain( 'radni', false, dirname( plugin_basename( __FILE__ ) ) . '/lang');
if ( ! $loaded ){
echo "<hr/>";
echo "Error: the mo file was not found! ";
exit();
}else{
echo "<hr/>Debug info:<br/>";
echo "WPLANG: ". WPLANG;
echo "<br/>";
echo "translate test: ". __('Some text','radni');
exit();
}
}
Error: the mo file was not found!
What i do wrong i read all docs from wp and nothing is changed!!!
Aucun commentaire:
Enregistrer un commentaire