We get quite a few emails asking how to translate our plugins so I thought it might be a good time to layout the process just a bit. The process is actually pretty simple but if you’ve never done it before and be a little intimidating.
The entire process is done in two steps.
- Internationalization: This is the process of making the plugin or theme ready for translation by marking specific strings of text. This is handled by the developer.
- Localization: This is the process of translating the strings and making WordPress serve the appropriate files. This is handled by anyone who wants the plugin in their own language.
What you will need
- A plugin (or even a theme) that has been properly internationalized. Both Ninja Forms and Ninja Announcements are translation ready.
- A gettext file editor like poedit. This is program that you will use to create your translation files
The files you will be using
There are 3 types of files used when translating a plugin, theme or even WordPress itself.
- .mo which stands for Machine Object. This is the file you will be creating for your custom translations.
- .po which stands for Portable Object. This is the file you will translate.
- .pot stands for Portable Object Template. This is the file by which the .po is created and is essentially the same as .po.
If your theme or plugin has been Internationalized you should find a folder named “lang”, “language, or similar. You will find at least some of the above mentioned files in there. Let’s get started.
1. Run Poedit and select File > New catelog from POT file
You will then to proceed to enter some details about yourself and then be prompted to save your work thus far.
There is a specific naming convention for these files in in order for WordPress to be able to serve them properly. It’s based on the language code (e.g. pt for Portuguese) followed by the country code (e.g. _SE for Sweden). For Swedish the file would be called sv_SE.po. See the complete list of language codes and country codes to find your exact locale.
For plugins it’s there is one more thing…the plugin name. So for our plugin Ninja Announcements the file would be named ninja-announcements-sv_SE.po.
2. Translate each the text
Poedit has three sections:
- The first section is a listing of all the the text available for translation. Click on a line to translate it.
- Beneath that it will display the current text you are viewing. This is just for reference.
- Finally, beneath that is the section where you will type your translation.
So all you have to do is click on a line. Translate the text and then move in to the next line until all the text has been translated. A star will appear in the first section to the left of each line that you have translated along with your translation to the right.
Be careful when typing in special characters. these sometimes need to be converted to what’s called “html entities”. Things like apostrophes, single quotes, ampersands, etc. check out this page for a listing of these entities to look out for.
Once you are done click “Save Catalog” button and your new files will be updated. You should be able to upload and test them out immediately.
Is your WordPress install ready for translations?
All this is great but if you install hasn’t been set up to serve the translated files it won’t make much of a difference.
To accomplish this you will need to change to your WordPress wp-config.php file with the correct language codes. Here is more info about getting WordPress in your language.
define ('WPLANG', 'sv_SE');
I hope you found this helpful and if you do translate any of our products please send us the file and your name and website. We would love to add you to the readme.txt of language contributors.