Below is a small tutorial of translation from English To German. (You can change the it as your needs).

in any plugin file, it has unique name in its header.

Plugin Name: SampleTut

in that plugin folder, make a folder (named "languages");

into your plugin .php file (somewhere in top), insert this initialisation code:

class load_my_language 
    public function __construct()
    add_action('init', array($this, 'load_translat'));

     public function load_translal()
        load_plugin_textdomain('SampleTut', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');

$ggg = new load_my_language ;

then open new text file and insert this code: (Now, we only make two messages, "helo" and "bye". You can insert as much as you need).

# English translations for PACKAGE package.
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2012.
msgid ""
msgstr ""
"Project-Id-Version: SampleTut 1.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-11 21:33-0400\n"
"PO-Revision-Date: 2013-11-21 12:33+0400\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"X-Poedit-SourceCharset: iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.4\n"

#: myplugininfile.php:47 (this is a note line)
msgid "mymessage1"
msgstr "Hello"

#: myplugininfile.php:48
msgid "mymessage2"
msgstr "Bye"

save this file and name it "SampleTut-en_US.po" (note, that .po should be an extension of the file, and not .po.txt)

download the software: POEDIT, and open that file and Press CTRL+S and thus, the program automatically generates the second functional .mo file ( If it doesnt generate the .mo file automatically, then edit preferences.); Then shutdown the program, and reopen the file again. Make your translations in "translation" fields, and after you finish, click SAVE AS and save the file as "SampleTut-de_DE" Now, the two German files will be generated.

then put those two English and two German files into "languages" folder.

Then, open wp-config.php and from default(English):

define ('WPLANG, '');

change to

define ('WPLANG, 'de_DE');

(This means, that we changed our wordpress main language. then worpdress will read our language file, with prefix -de_DE)

so, now open your plugin's .php file, and where you have any echo-ed word:

echo "Something";

change to :

echo __("mymessage1", 'SampleTut');

or the same as echo:

__e("mymessage1", 'SampleTut');

And thus, the wordpress shows you the appropriate translation for that id (mymessage1).


  • 5
    Is this a question? If not, you should make a question out of it and post your tutorial as answer and mark it as solution two days later. Please also get in touch with the WYSIWYG editor, which will help you format this properly. – kaiser Mar 27 '13 at 14:37
  • 1
    Nice contribution, but take a look at the pages About and FAQ to format this in a Question & Answer fashion. – brasofilo Mar 27 '13 at 14:46
  • instead of echo __($string) try its shorthand _e($string). More of these: codex.wordpress.org/L10n – Jan Beck Mar 27 '13 at 18:53

Do not create a PO file manually. The synchronization must be automatic, or you will waste much time. Each you change a string, you have to change it in two files now.

Poedit has a built-in PHP parser. Use it to read your project files.

enter image description here

And you don't have to edit WPLANG to create a translation.


You can also use Codestyling Localization plugin.

It's even easier to use than Poedit and you don't have to install any programs on your computer. You can translate everything directly in your wp-admin.

It will scan your plugin files and find all strings to translate. Then you can translate them to any language you like.

Not the answer you're looking for? Browse other questions tagged or ask your own question.