Unable to translate wordpress plugin using poedit

I am trying to translate my wordpress plugin, I have followed the following steps :

  1. Firstly, I created .po file in /plugin/languages folder using poedit
  2. Then in wp-config file I put the code

    Read More

    define ('WPLANG', 'ajaxEdit-aa_AA');
    define('WP_LANG_DIR', $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-content/plugins/wp-ajax-edit-comments');

in the file I have written the code to be translated as follow :

<?php _e('Behavior', 'ajaxEdit');?>

when I am removing the ajaxEdit from _E() then it is being translated but when I am using ajaxEdit then it is not being translated.
what should I do to translate the plugin using this ajaxEdit

Related posts

Leave a Reply

1 comment

  1. If you are using a text domain, and you are encouraged to do so, you need to declare it somewhere in your plugin. I think that, somehow, when you do not declare a text domain, it uses the default that you have set in the wp-config.php.

    After trying several hooks on my own plugin, this is the one that worked for me, put this at the very beginning of the file:

    add_action('init', 'yourplugin_init');
    
    function yourplugin_init() {
        load_plugin_textdomain('ajaxEdit','',plugin_basename( dirname( __FILE__ ) .'/languages' ));
    }
    

    The first attribute is the text domain you are using (the same you use as a second parameter in the e() or _() function to point at the right translation files). The second one is empty, it’s not used because it is deprecated. Then, the third one: it is the location of the files. In this example, the translation files are in a subdirectory, inside the plugin, which is the best way to pack it. So I would recommend you to move your files to that directory. Just remember not to use underscore for the domain name (it’s not your case, anyway).

    WPLANG is used to set your site main language, which will be taken by the plugins, themes, system backend, and everything that has a translation. Its typical attributes ar an ISO-639 language code followed by the ISO-3166 country code like: pt_BR, pt_PT, es_ES or es_AR. In this case, you seem to be doing something not recommended at all, even if you get it to work.