All of our products are first made with the English language in mind; it’s the most universally-spoken language among our users, so we want to make sure that the vast majority can read and understand what we have to offer. Still, for many users English is their second language, and once they’ve added our products to their site the first thing they’ll want to do is translate the content to match what their users want. To help people along with this we make sure to include language files in everything we do, but for some beginner users, or those with limited translation experience, actually getting things done can be a challenge. In this article, we’ll look at how you can get your translation sorted and provide some important steps you need to follow.
Translation methods
There are two common methods for translating content that we can consider; we could use an application such as PoEdit to create our po and mo language files that we can then upload into the plugin or theme directory. Alternatively, we can use CodeStyling Localization to simplify the process somewhat; a more effective option for those uncomfortable with manipulating files via FTP.
Method 1 – preparing our files in external application
This method doesn’t need to be described in-depth, since we have a complete guide to translating our themes and plugins in its own article in our documentation. However, the basic steps can be easily summarized. First, download the Poedit translation editor; this is a far more important step than you may realize, due to the necessity of po and mo files using UTF-8 encoding. Basically, if you’re using a basic word processor such as Notepad to modify your text files you may find that despite everything being in order when looking at the file, the actual translations are not applied in your WordPress environment due to the lack of proper encoding. There are plenty of ways to get around this, most very simple, but all this hassle can be avoided simply by downloading PoEdit, so why make things harder?
With PoEdit installed, you can now use it to open our pot file, translate all the elements into your chosen language as needed, and then upload the po and mo files via FTP into the theme or plugin directory where they will be put to use. Another extremely important point to remember is the naming convention for language files; if the rules aren’t followed then the translation just isn’t going to work. For example, if we were to translate our Steakhouse contact plugin into Polish, the resulting mo file would be named gk-contact-steakhouse-pl_PL.mo. This name is made up of two parts; first, the gk-contact-steakhouse part refers to the plugin directory name. Second, the pl-PL section refers to the language of the translation, using the standard language codes; lower-case pl indicating the language, and upper-case PL representing the country of origin (i.e. a British-English translation of the file would be en-GB; English language, British origin).
Method 2 – The Codestyling Localization plugin.
This method is a useful alternative to the method above, but unfortunately it doesn’t have an in-depth article of its own so we’ll have to look at it step-by-step to get things working; don’t worry though, it is a very simple process. For this example, we'll use our GK Contact Steakhouse plugin. To apply the translation:
1. Navigate to Plugins → Add New in your WordPress admin area and run a search for Codestyling Localization; this should lead you to the correct plugin, so run the install option so that WordPress downloads and installs the plugin as needed. Don’t forget to activate the plugin after installation is complete, or things will take quite a bit longer to finish!
2. Now we can navigate to Tools → Localization in the left menu to open the options for our new plugin.
3. Now we click the Plugins tab; this will give us a list of installed plugins. Find our contact plugin in the list and choose it.
4. If we can't see the language we’re translating to in the right sidebar, we’ll need to create a new instance of the language by clicking the Add new language button.
5. Pick your language from the line-up and then click on create po-file; the plugin will get to work and create the relevant files.
6. Next, we click the Rescan button; this makes the tool look for all the translatable words inside our plugin, which we’ll need if we’re gonna make changes! Clicking the button will open a new window; we only need to click the scan now button to move to the next step.
7. When the scan is finished we click on the Edit button to open the translation interface, where we may translate each string one-by-one.
8. Move through each string, creating the new translations as required.
9. Once we’ve battled through adding all of the translations, we can click on the generate mo-file button. Without the mo file our translation won't work properly, so it’s really important to make sure you generate this file everytime you complete a new translation, or make changes to an existing translation such as adding new words or definitions.
10. The translation is now ready, but you probably still can’t see it. We have to set the language in our WordPress website accordingly for the changes to take effect. In WordPress 4.* this is very simple; you may make the necessary change in your Dashboard → General settings.
And that's it; once this is finished you should see all the translated content on your site as needed:
We hope this information is useful, and we encourage all of our users to share your translations of our plugins and themes with others to make getting up and running even easier for newcomers. If you’ve made a nice translation please send the translated files to us and we'll put them on the forum or include them in the theme/plugins files so everybody can enjoy the benefits.