Posted on

Translating WordPress Themes and Plugins

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.

Poedit user interface

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:

WordPress plugin before translating
Translatable strings are highlighted

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:

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':

Translated WordPress plugin
Translated strings are highlighted, I hope I got it right :)

A Quick Wrapup

Translating a WordPress theme or plugin is a two step process:

  1. Translating text strings using Poedit
  2. 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

Free Marketing Updates
Get the best marketing practices in your inbox.
We always respect your privacy.

Share
Slobodan Manic
I love working with WordPress and doing it the right way. Themes and plugins I develop have a common #1 goal: Keeping it as simple as possible for users to publish their content.
Slobodan Manic

@slobodanmanic

Web consultant with 10 years of experience in web development and web analytics.
Slobodan Manic
Slobodan Manic

Latest posts by Slobodan Manic (see all)

11 comments Translating WordPress Themes and Plugins

  1. Hi,
    using poedit really made translation of your Fancier Author Box easy – it speaks german now \o/

  2. 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.

  3. 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?

  4. 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”.

  5. 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?

  6. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.