translating a Wordpress plugin

translating a WordPress plugin

I just had the pleasure in translating a WordPress Plugin and found not only one, but many tutorials, I want to summarise my search results. Without big code-snippets or samples.

Like in many other articles I downloaded and used  Poedit.


The following steps guided my to a successful translation:

    1. within wp-config.php the language musst be set: define(‘WPLANG’, ‘de_DE’);
    2. In the main file of the plugin you need the following changes / additions:
      1. In the header you need the attribute Text-Domain, e. g.
        Author: Robby Jansch
        Text Domain: plugin_name
      2. the language file needs to be loaded:
        add_action('plugins_loaded', 'plugin_translation');
        function plugin_translation() {
            load_plugin_textdomain( 'plugin_name', false, dirname( plugin_basename(__FILE__) ) . '/language/' );
    3. mark the parts you need to translate with _e("text to translate", "plugin_name") or one of the other translations. I started with the english text and made the translations into german.
    4. now we need in the root-folder of your plugin a folder called language
      1. with Poedit (i’ve downloaded it to my Mac and did all the translation local) you can create the language files.
        The Format of the filenname must be: [plugin-name]-[locale] so it is here  plugin_name-de_DE
      2. Poedit creates the right .po files
      3. Now you can search with Poedit through your sourcecodes for _e or __ or any other function. You can define these keywords within the poedit-language-files-settings
        Schlüsselwörter definieren
      4. make you translations, save it an move the  .po and .mo files to your webserver
    5. Test it and be happy