Support » Plugins » How to use I18N for plugin?

  • Hello,
    I’m writing a small plugin (called wp-version on the wordpress plugins repository) and want to internationalize it. I follow all the steps in the I18N page, but obviously I miss something. I also looked how other plugin do, but it still doesn’t work for me.

    What I do :

    – I used _e(XXX, “domain name”) for all the string I want to translate
    – I used the repository to generate the .pot file
    – I used POEdit to generate the fr-FR.po and filled with translations.
    – I added in my main plugin file :

    function wp_version_init() {
    	$wp_version_domain = 'wp-version';
    	load_plugin_textdomain ( $wp_version_domain,'','wp-version/lang/');
    add_action('init', 'wp_version_init');

    I found this way to proceed on another plugin. Is this OK?

    THen, when I activate my plugin on my french wordpress, it works but everything is displayed in english (the langage I used in the _e() commands). So I don’t see what I do wrong.

    I’m fighting with that for a long time now, any help or suggestion would be deeply appreciated !!!

    Many thanks to everybody.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Naoko Takano


    Happiness Engineer at Automattic

    The paths in load_plugin_textdomain() don’t seem right. Try:

    load_plugin_textdomain($wp_version_domain, 'wp-content/plugins/wp-version/lang', 'wp-version/lang');

    Good luck!

    Hello Nao,
    Many thanks for your answer. Unfortunatly, it still doesn’t work… I continue to have my english sentences displayed.

    I have a subsidiary question : my plugin is shaped in 2 php files (wp-version.php, which is the main file and version-admin.php which contains the admin interface). The load_plugin_textdomain() function should be called only one time, on the init action? Or should I add it also in my other php file?

    If you have some spare time, would you mind to have a look on my small plugin?

    Once again, I couldn’t tell how deeply appreciated it would be !!

    Many thanks


    An update from my work on the problem this morning :

    • I echoed the functions load_plugin_domain() and translate() to see the output. As far as I saw, it found the locale, it found my .mo file ( but still writes in english…
    • I looked as other plugin I have installed, and some of them use the hook ‘init’ to load the plugin domain and the translations, some of them directly load it. So what to do? I have at least one plugin with the french translation working, so my browser configuration seems OK.

    I hope it can give clues about what’s happening… Once again, many thanks to those who will spend time on my problem !



    Hello back,
    I’m still stuck, with no really clear reason… Anyone would have a candle in the dark for me ;)?

    Many thanks in advance ,


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to use I18N for plugin?’ is closed to new replies.