WordPress is the most popular open source content management system in the world. It is used by hundreds of millions of users to create websites in many different languages. Recently, one of our users asked us how they can translate a WordPress theme into their local language. WordPress itself is available in many languages, and there are also numerous WordPress themes and plugins that have translations for multiple languages. Most of the time, these translations are done by users like yourself. Most WordPress themes and plugin authors welcome community users to help translate their work into other languages. In this article we will show you how to find and translate a translation ready WordPress theme.
Finding a Translation Ready WordPress Theme
Even though WordPress has great support for creating websites in any language, theme developers may not find it necessary to create translation ready themes. If you are going to create a website in a language other than English, then you need to make sure that the theme you are purchasing or downloading is translation ready.
If you go to the WordPress theme directory’s tag filter interface, then you will see a list of option, which are actually tags theme developers have added to their themes. Check the box next to translation ready option. If you are going to translate your theme into a right-to-left language like Arabic, Hebrew, and Persian, then you should also check rtl-language-support option. Click on the Find Themes button, and you will see the results that match your query. You can further narrow down your search by checking other options in the tag filter.
Most good commercial themes and frameworks are also translation ready. However if you are unsure, then you can always ask them before making your purchase.
How to Translate a WordPress Theme
After you have found a translation ready WordPress theme, download the theme on your computer and extract the theme files. In the extracted files, you will find languages folder. This folder should have a POT file, or in some cases there might be a .po or .mo file.
What are .pot .po and .mo files
WordPress and WordPress themes use a system called gettext for translations, localization and internationalization. In gettext the programmers use gettext calls for every translatable area of the program. These calls are then collected in a POT file. So basically a POT file is a template of translatable strings in a program.
Using the POT file, translators then generate a .po (Portable Object) file for their language. The name of the file refers to the language it is for. For example, a French translation file would be named fr_FR.po. Basically this is the file that you will be translating.
Lastly the .mo files are the machine readable format of the .po file. It is generated from the .po file, so you don’t need to create it.
Translating using Poedit
You can simply edit .pot and .po files in any text editor of your choice. Most linux based distributions come pre-installed with command line tools that can be used to generate .mo files. However, since you are just starting out with localization, it is highly recommended that you use a gettext editor. In this tutorial, we will show you how to translate a WordPress theme using Poedit, which is a gettext editor available for Windows, Mac and Linux. It is very easy to use and will help you quickly translate your WordPress theme without breaking translation files.
First thing you need to do is install Poedit. If your theme came with a .pot file, then go to File » New catalogue from POT file…. Select the pot file that came with your theme. When you open the pot file, Poedit will show you another dialogue box asking information about the project. The most important field here is language.
When you fill in the catalog properties box, Poedit will ask you for your saving preference of the translation file. The translation file will be saved with a .po extension. The name of the translation file is very important. The format is to save it in two letter language_country code. For example, a French translation for France should be saved as fr_FR.po, an Arabic translation for Egypt will be saved as ar_EG.po, and an English translation for United Kingdom will be saved as en_UK. You can find your country and language code here.
After saving your file, you are now ready to translate your WordPress theme.
Poedit has a very simple interface. It lists all translatable strings, you can click on any string to translate it. There are three boxes below the list. One for the original string, second for the translation and the third box would show instructions for translators. When you translate a string, Poedit will automatically move to the next string in the queue. When you save your file, Poedit will automatically compile a .mo version of the file in the same directory.
Once you are done translating your theme, upload the theme to your WordPress website using FTP. Go to WordPress admin area in your browser and activate the theme.
Setting WordPress to Use Translated Theme
If you are already using WordPress in the same language as your theme’s translation files, then WordPress will automatically pick up translation files for your theme. However, if you are using WordPress in default English, then you can still force WordPress to use translated files for the theme. Simply add this line of code in your wp-config.php file:
// Replace fr_FR with your language and country code. define ('WPLANG', 'fr_FR');
By adding this line you are telling WordPress to use translation files for these languages. However, since you are not using WordPress in that language and there are no translation files for WordPress backend. WordPress admin area will fallback to English, but your theme will be displayed using the translation files.
We hope that this article helped you translate WordPress theme into your own language. If you are not a developer, and you want to contribute back to the community, then translation is one of the best ways to give back to the larger global WordPress community. Most theme and plugin authors really appreciate user involvement and some might even reward you by giving you extra support, PRO add-ons, etc.
Let us know if you have any questions or feedback by leaving a comment below.