If providing support for our premium author box plugin has taught me anything, it’s the fact that most WordPress end users are not aware of how easy it is to translate a WordPress theme or plugin. As a developer, I’d happily translate everything I code into every language there is, but Google Translate is not really that good, is it?
Luckily, you can translate a theme or plugin without even catching a glimpse of PHP or CSS code, presuming it’s translation ready, of course.
What Translating WordPress Themes and Plugins Really Means
No, it doesn’t translate your content, sorry. If that’s what you need, check out WPML plugin.
Translating a WordPress theme or plugin means translating text strings that are used throughout it.
For example, if you’re using a plugin to show a list of related posts, you should be able to translate “Related Posts” heading to your language, if the plugin is translation ready.
Is My WordPress Theme/Plugin Translation Ready?
If you can find .pot and .mo files anywhere in your plugin or theme folder, then yes. They’re usually located in /languages subfolder, so you probably won’t have to wander.
Now that you know it is doable, let’s see exactly how easy it is.
Required Tools for Translating WordPress Themes and Plugins
Translating WordPress Codex page has a long list of tools you may use, but let’s focus on one them — Poedit — mainly because it’s open source, easy to use and available for all major operating systems.
Other than Poedit, you’ll need some time and knowledge of at least two languages, but that’s all.
Translating WordPress Themes and Plugins
Fire up Poedit and load .pot file from your theme or plugin. All strings developer has made translatable are immediately shown and you can translate each one of them. Screenshot above uses translation files for a WordPress plugin I created for this tutorial. All this plugin does is add one heading before post content and another one right after it:
After you’re done translating all the strings, hit Save, then Save As to save your new language file and name it like this:
original_file_name-{language_code}_{country_code}.po
Make sure the file is in the same folder as the .pot file you opened. For language and country code reference, check out:
- List of ISO 639-1 codes for language codes (you need a two letter 639-1 code)
- List of ISO 3166-1 codes for country codes (you need a two letter Alpha-2 code)
So, if I’m translating plugin used in this example to Portuguese, filename would be thsp_translation-pt_PT.po, because the original file was called thsp_translation.pot. Another file with .mo extension will be auto generated, don’t worry about it.
Telling WordPress Which Language it Should Use
Now that you have created language files, you need to instruct WordPress to use them. WordPress Codex already has switching to another language perfectly explained, but here’s the gist of it:
- Open wp-config.php (usually located in root of your WordPress installation) in a text editor
- Locate the line that says
define('WPLANG', '');
- Change it to
define('WPLANG', '{language_code}_{country_code}');
(see above for language and country code explanation) - Save the file, upload it to your server
Here’s how plugin used in this example behaves when WPLANG
is set to 'pt_PT'
:
A Quick Wrapup
Translating a WordPress theme or plugin is a two step process:
- Translating text strings using Poedit
- Telling WordPress which language it should use
But there’s also a recommended third step — sending developers language file you created so they can include it in a future version. That last step is what makes this entire process a win-win-win:
- You get the credits for helping other people
- Developers get more downloads because more people can use their products
- Other WordPress (non English speaking) users can use a theme or plugin in their own language
So go ahead and try it. Does your theme or one of your favourite plugins not include translation to a language you speak? Our Fanciest Author Box plugin only has 91 text strings, most of them very short. A lot of plugins have even less. Or you can grab one of those cool free premium WordPress themes Dragan covered in his post and translate it.
And make sure you come back here and let us know if it was easier than you thought it would be.
Featured image credits: Mathew5000
Hi,
using poedit really made translation of your Fancier Author Box easy – it speaks german now \o/
Henning,
Glad the article helped :)
If you don’t mind, please send us the translation files, so we can make them available for all users, giving you the credits, of course.
Hi,
My question is: How can I install a WordPress theme like using two languages? Belgium has french and dutch and I want english too. How to do that?
When some users come on the site they should be able to choose language like dutch french or english. I can translate myself po.files, I need just translate strings nothing more. How is it with wordpress and theme, do I need use plugins or make subdomains install WordPress and theme with french translation then again subdomain WordPess and dutch, or no?
Hi,
For what you’re trying to achieve, you’d need a multilanguage plugin. I suggest you take a look at WPML, as far as I know, it’s the best one out there.
http://wpml.org/
Hi,
I translated the plugin Fancier Author Box strings to Dutch language. I will send you the files per e-mail.
One question: If I update the plugin in the future, will my .po en .mo files be removed? I placed them in the plugin’s subfolder “languages”.
Winy, thanks for the translation, and no worries at all, we’ll include the language files with next plugin version.
Hey! If you’re interested in a tool to easily translate WordPress themes, have a look at this https://poeditor.com/ You can also download a plugin to integrate its API to your WordPress so that you save more time with the file management process – http://wordpress.org/extend/plugins/poeditor/ I highly recommend it.
Thanks so much for the link. We’ll check it out.
I just found that using WordPress Language, the plugin doesn’t recognize the local language. I had to manually set the language of the site in wp-config. I guess this will also cause the same issue for multilingual site using wpml.
Is there any way to get around this so the plugin recognizes the language without being hardcoded in wp-config?
As far as I know that’s the only way to do it, by chaning it in wp-config.php
I want to translate theme wordpress. This my code have _e(‘text’). This text can anble translate. But i don’t know use what plugin