0

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

  • The WPLANG constant is not helpful since 4.0. You have a settings field inside the general settings of the install. Is your install in sr_RS? Also helpful for debugging is the plugin Debug Objects, list all translation, there called via hook and his path, that you see, what is wrong. Have you also the hook on init in a other function, method? – bueltge Mar 3 '15 at 21:44
  • Thanks for replay. By default i download en version. No i dont have hook on init in other method – Ivan Mar 4 '15 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.