Home/Knowledge Base/Tutorials/How to translate WordPress theme?
How to translate WordPress theme?

Translating a WordPress theme in your language is an easy task and does not require any coding or programming skills as long as the theme you are about to translate is Translation ready. A translations ready theme means that the theme creator has implemented some sort of coding to make all the theme hard-coded text (such as the 404 error message) and labels (such as “About the author:” & “Continue reading”) so they dynamically change to their corresponding translations when a non-English language is choosed. Making a theme translation ready (also called Internationalization and abbreviated as i18n) is the theme developer work so you don’t have to worry about this before trying to translate any WordPress theme, please make sure it’s advertised as translation ready.

WordPress uses the GNU gettext localization framework for translation which involves the use of 3 type of files:

  • POT (Portable Object Template) files: These are the template files for PO files (Microsoft’s PowerPoint template files are also using the .pot extension, but they are not the same).  Generally, these files are generated by a tool that search through the theme source code and log the text passed into a __() function (& other 3 functions).
  • PO (Portable Object) files: These files contains the same strings that has already been logged in the template file alongside their corresponding translations.
  • MO (Machine Object) files: These files are machine readable generated from the PO files.
Easiest way to check if a theme is translation ready is to look for .pot file inside the theme folder. Most developers put these files in a “language” or “lang” folders. If you find that file, then your theme is ready to translate.

Translating WordPress theme using Poedit:

There is more than one way to translate a WordPress theme. For the sake of this tutorial, we are going to use Poedit; an open source program available for Windows, Mac OS X and Linux that will make translating WordPress themes a piece of cake!

    1. Download and install Poedit.
    2. When installed, open Poedit and click Create new translation and select your theme POT file. As I already said, your theme .pot file should be available somewhere in your theme folder. Most developers place this file in sub-folder named “lang” or “languages” .

Create WordPress translation

    1. Now a Translation Language box will popup asking for the language of translation. Select the language and click OK.

Poedit select translation language

    1. Now you can start translating your theme. Poedit has a very intuitive and user friendly interface. The Source text field will show the currently selected string. To translate this string, put the cursor inside the Translation field and type the translation. Poedit will try to help you and suggest you human translations for the selected string. Please note that the free version of Poedit will only show you 10 suggestions which will reset each time you close Poedit.

How to translate WordPress theme

  1. Every string you translate will be saved in a database and each time Poedit detects this string, it will show you your old translation as a suggestion. You are free to translate all the strings or only few of them. This is totally up to you!
  2. When you’ve finishing translating, simply Save the file. Poedit will automatically create both .po and .mo files in the same folder where the POT file is placed.

Now that your theme has been translated, you are ready to apply the translation!

Applying your translation:

To change your theme language, simply open wp-config.php file (located in your main WordPress installation folder) with any code editor and add this line at the bottom of the file:

define ('WPLANG', 'ar');

Remember to change “ar” to the name of your PO file.
Note this will not change the WordPress backend language. It will only change your theme language. If you change the backend language from the WP General Settings page and your current theme support this language, it will be applied to the theme too without the need to edit the wp-config.php file, automatically!

Please be aware that both .po and .mo files must be named in particular format. For example, if you’re translating to Arabic, the files should be named ar.po & ar.mo, and for French translation for France, the files should be named fr_FR.po & fr_FR.mo.

Was this Helpful?

(83 out of 198 people found this article helpful)