I want to translate this plugin.
The plugin has already been translated into other languages and it has .pot
files for adding new languages (as far as I understood from description).
How do I create .po
and .mo
files for my new language and make them accessible so as to be used by the plugin? I’ve tried to define Russian language in my wp-config.php
file by inserting the definition below:
define ('WPLANG', 'ru_RU');
The Editor
There are others, but this is most used: Poedit, a cross-platform gettext catalogs (.po files) editor.
The Formats
.mo
stands for Machine Object— compiled export of the
.po
file which is used by WordPress.po
stands for Portable Object— editable text file with the translations strings
— based on the master
.pot
file, using Update from POT file PoEdit function— some folks distribute this as a master file, but it should be used only for translations
.pot
stands for Portable Object Template— editable text file used to grab all the translatable strings from WordPress itself and Themes and Plugins, using Update from Sources PoEdit function
The Procedure
plugin-basename-lang_COUNTRY.po
subscribe-reloaded-pt_BR.po
— pt_BR means Portuguese Brazil, but many languages don’t have a country variation…
— you’ll have to fill in with your own language
WPLANG
inwp-config.php
file must be set to your language, e.g.,pt_BR
.po
file, PoEdit automatically generates a.mo
file, which is the one WordPress uses and basically the only one you need to uploadObservations
You can try this codestyling-localization plugin:. You can translate you plugins and themes using this.
(Here is an EXAMPLE of translation to DEUTSCH. CHANGE the customs to YOUR DESIRED ones.)
in every plugins head, there is an unique name.
(for example:
then, in that plugin’s folder, create a folder “languages”;
then, into your plugin .php file (somewhere in the top), insert the initialization code:
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).
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:
and change to
That’s all.
When WordPress is loaded, it will read your plugins language file, with prefix -de_DE.
So, in the plugin’s .php file, instead of:
you should use:
Finished. Now you should test your plugin.
p.s. used links:
You will want to use POEdit. It’s a free application for creating .po/.mo files.
I wrote a pretty in-depth tutorial on the entire topic here. You can skip to Step 3 – Create the Translation File For Text Domain.
I suggest also http://poeditor.com/. It is a web-based translation tool that works great with .po, .mo, .pot and other types of files.