To translate WordPress themes, they must be properly internationalized which means (Ready for Translation). In our previous guide, How to create Multilingual WordPress Theme, we went through the precess of creating a fully internationalized WordPress theme. The next step is to translate the internationalized theme using POEdit software.
Other ways to translate WordPress themes?
Of course, there are many other ways to translate WordPress themes. You can use a multilingual plugin (like Polylang, Weglot or WPML). In this guide, The Definitive Guide: Create a multilingual WordPress site, we explained multiple options to translate your WordPress site into multiple languages including your themes and plugins textual content.
In this post, we are using POEdit to translate WordPress themes.
Before you start translating your WordPress theme, you must have the following:
- Translatable WordPress Theme.
- .POT file – If you don’t have this file, you will need to create one.
- A free version of POEdit software.
Simply, you need to use POEdit to open the .POT file to create .po file and transform it into .mo files.
What are .POT, .PO and .MO?
- POT (Portable Object Template): a file that contains every translatable string or text.
- .po (Portable Object): It’s the file created when you translate your POT file to a particular language. For example, fr_FR.po
- .mo (Machine Object): It’s the file that the machine can read, it’s a binary file. You’ll have to convert your .po file to .mo file. For example, fr_FR.mo
1- Open POEdit -> File -> New
2- Choose the language you need to translate your theme into.
3- Click on “Update from POT”.
4- Save the file as it suggests to you (the language code; for example fr_FR.po, es_ES.po, etc…)
5- Open the POT file, it is usually located in languages (or lang) folder inside your theme folder.
6- Start translating your theme strings using POEdit.
7- Once you are done with the translation, click File -> Save.
8- Create the .mo file by going to File -> Compile to MO.
9- Move both .po file and .mo files to languages folder in your theme directory. It might be called lang.
Yes, I have found this plugin Loco Translate. It allows you to create language files via WordPress admin.
- Built-in translation editor within WordPress admin
- Create and update language files directly in your theme or plugin
- Extraction of translatable strings from your source code
- Native MO file compilation without the need for Gettext on your system
- Support for PO features including comments, references, and plural forms
- Configurable PO file backups
- Built-in WordPress locale codes
Translating WordPress themes is an easy task, but it might take you some time as you will be translating all the textual content of the theme. Once you have the theme’s POT file all you need to do is translate it to create the .po file then convert it to a .mo file and copy both (.po and .mo) files to you theme’s language directory. Congratulations! Now you have your theme translated.
If you have any issues or questions, don’t hesitate to post them in the comments below.