(Here is an EXAMPLE of translation to DEUTSCH. CHANGE the customs to YOUR DESIRED ones.)
in every plugins head, there is an unique name.
Plugin Name: my-pluginname
then, in that plugin's folder, create a folder "languages";
then, into your plugin .php file (somewhere in the top), insert the initialization code:
public function __construct()
add_action('init', array($this, 'load_my_transl'));
public function load_my_transl()
load_plugin_textdomain('my-pluginname', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
$zzzz = new load_language;
then open any text editor, then insert like this code (NOTE, THAT we are only adding two sample messages, "hello" and "bye", so , you can ADD AS MANY messages AS YOU WANT with the similar lines).
# English translations for PACKAGE package.
# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Automatically generated, 2012.
"Project-Id-Version: my-pluginname 1.0\n"
"POT-Creation-Date: 2012-08-06 13:46-0400\n"
"PO-Revision-Date: 2013-03-21 11:20+0400\n"
"Last-Translator: Automatically generated\n"
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.4\n"
#: mypluginindex.php:87 (it is just a line of a note, to remind where our code appears)
then save this file as "my-pluginname-en_US.po" (note, that .po is an extension of file, so check that your text editor program has not saved to "my-pluginname-en_US.po.TXT").
then download POEDIT software, and open this file. then edit the "translation" field, and then save as "my-pluginname-de_DE"
there will be generated two files ( If poEdit does not generate the second .mo file automatically, just go to File -> Preferences -> Editor and check the box that says "Automatically compile .mo file on save"),
then put those two file into "languages" folder.
after this, open wp-config.php and find this code:
define ('WPLANG, '');
and change to
define ('WPLANG, 'de_DE');
When WordPress is loaded, it will read your plugins language file, with prefix -de_DE.
So, in the plugin's .php file, instead of:
echo "Something string";
you should use:
echo __("mymessage1", 'my-pluginname');
Finished. Now you should test your plugin.
p.s. used links: