How to Translate a WordPress Theme
Translation is one of the most highly requested topics in the WPMU DEV support forums, and it’s no wonder. According to recent statistics, WordPress is available in 205 languages.
71% of WordPress’s published pages use English in their content. That’s a lot of people who probably speak English as a second language―and also people who develop websites for those who might not speak English at all.
As such, we’re kicking off a series on translating WordPress. Over the next week we’ll feature a new post every day on translating different aspects of WordPress. If you have any requests please me know in the comments below.
In this first post I’ll show you how to translate a translation-ready theme.
- Finding a Theme Ready to Translate
- Translating Using Poedit
- Setting Up Your Translated Theme in WordPress
- Translation Tips
This post is part of our Translation Week series. Check out the other posts in this series here:
- How to Translate a WordPress Theme
- How to Localize a WordPress Theme and Make it Translation Ready
- How to Set Up the WordPress Backend in Your Language
- Everything You Need to Know About Translating WordPress Plugins
- Collaborative Translations Now Available for WPMU DEV Products
- How to Translate a WordPress Plugin
- Top 6 Translation Plugins for Your WordPress Site
Finding a Theme Ready to Translate
First things first, you’ll need to find a theme to translate. But you can’t just translate any old theme – you need a theme that has been localized using the GNU gettext framework. In other words, the theme is ready to be translated. If your theme hasn’t been localized, come back later this week for a run down on how to make your themes translation ready.
Developers don’t always create translation ready themes, so when you’re buying a premium theme make sure to ask if it’s translation ready.
If you just want a free theme, it’s easy to search for translation ready designs in the WordPress Theme Repository.
Go to the WordPress.org Themes repository.
- Click on the Feature Filter cog icon.
- Under Features, scroll down to Translation Ready at the bottom, and click to checkmark the box next to it.
- Then head back to the top of the page, and click on Apply Filters.
Once you’ve got your theme, open up the zip file and find the language folder. It should contain a POT file.
WordPress uses the GNU gettext localization framework for translation. There are three types of files used in the framework:
POT (Portable Object Template) files: The first step in the translation process is using a program to search through the WordPress source code to pick out text passed into a
__e() function, generating a POT file. This file will contain all the text available for translation.
PO (Portable Object) files: The second step involves translating the text in a POT file into the target language, saving both English and translator messages in a PO file.
MO (Machine Object) files: In the last step, the PO file is converted into a machine readable format.
Translating Using Poedit
There are a few different options for translating WordPress, as outlined in the WordPress Codex. For this tutorial, we’re going to use Poedit, an easy to use open source program available for Mac OS X, Windows and UNIX/Linux.
1. Install Poedit.
2. Open Poedit and go to File > New catalog from POT file and select the POT in your theme’s languages folder.
3. A catalog properties box will pop up asking for information about what you are translating. Enter the language you want to translate here.
4. Afterwards, you’ll be asked what you want to name your translation file. The name is important and there’s a particular format you will need to follow. For example, if you’re translating Chinese for China, the file should be name zh_CH.po, and for a Tagalog translation for the Philippines would be tl_PH.po
Check out the GNU `gettext’ utilities to find your language and country codes.
Save your file in the languages folder of your theme.
5. Now you can start translating your theme. Poedit has a simple and straightforward interface that doesn’t involve a steep learning curve. The space at the top will display all the text ready to translate, and any completed translations will display to the right. The boxes underneath show the source text you’ve selected to translate, your translation and any notes for translators.
Translating a line of text is really easy―just select a word or phrase, enter your translation and click Update.
6. When you’ve finished translating, simply save your file. Poedit will automatically create both .po and .mo files in your theme’s languages folder.
7. Now that your theme has been translated, you can upload it to your WordPress install either using FTP or by logging into your WordPress site and uploading your theme by going to Appearance > Themes, then clicking on the Add New button (after you’ve zipped your theme, of course).
Setting Up Your Translated Theme in WordPress
As English is the default language for WordPress, you will need to play with a little code to force WordPress to use your translated files.
In order to do this, you will need to FTP into your WordPress install and open up the wp_config file and add this line of code:
define ('WPLANG', 'zh_CN');
This line specifies Chinese for China, so you’ll need to replace zh_CN with your language and country code.
Adding this line tells WordPress you want to use translation files for Chinese. Since you’ve translated only your theme and not your backend, your site will display in Chinese but your WordPress admin area will continue to display in English.
I’ll cover changing the default language for your WordPress backend in another post as part of this series this week.
The WordPress Codex offers some solid tips for translation that anyone translating WordPress should keep in mind:
Don’t translate literally, translate organically: Languages have different structures, rhythms, tones, and inflections. Translated text don’t need to be structured the same way as the English ones: take the ideas that are presented and come up with a message that expresses the same thing in a natural way for the target language.
Try to keep the same level of formality (or informality): Try to accomplish the equivalent in the target language, within your cultural context.
Don’t use slang or audience-specific terms: Stay away from colloquialisms and to stick with what you think a new blogger would understand.
Read other software’s localizations in your language: If you get stuck or need direction, try reading through the translations of other popular software to get a feel for how they have tackled translations.
Editor’s Note: This post has been updated for accuracy and relevancy.
[Originally Published: October 2013 / Revised: March 2022]