Τranslate your Plethora WP theme using PO/MO/POT files
Latest update: April 15, 2021 | Reading time: 4 to 5 minutesWhat’s this about?
This is a straightforward tutorial that will help you translate a Plethora WordPress theme in your language. Careful, this is the suggested procedure for a localized website ( single language ). If you need a multilingual website, you should consider installing a multiple translations plugin such as WPML.
Software/resources needed
The only thing you need is a Gettext translations editor. In this tutorial we will use Poedit editor, which is one of the best out there…and it’s free!
Things to know about PO/MO/POT files
All Plethora themes are translation-ready and come with the related Gettext files (PO/MO and POT files). Consider those files as a catalog containing every single text string used on your theme. What you need to know about them:
- PO files are the files that contain the actual translations. Each language will have its own PO file, for example, for French there would be a fr.po file, for German there would be a de.po, for American English, there might be en-US.po.
- MO files are the compiled versions of PO files and they always have to be together. In our case, you won’t have to deal with it, as it is created automatically by Poedit.
- POT files are basically the template files for PO files.
- You can find those files on the /language folder under your Plethora theme’s root directory
Fine…let’s translate!
- Open POT file with Poedit
- Go to File > Save as and save your PO language file. As stated above, you should name this file using your language code. 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, an Arabic translation for Egypt will be saved as ar_EG.po, and an English translation for the United Kingdom will be saved as en_UK. You can find your country and language code here.
- Now you are ready to translate your theme. Poedit lists all translatable strings and you can click on any string to translate it. There are three default boxes below the list. One for the original source text, the second for the translation and the third one would include notes for translators. Every time you save your file, Poedit will automatically compile a .mo version of the file in the same directory.
- After finishing your translation ( it works even if you have not translated all strings ), upload those files to your /language folder using FTP.
- 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 your translated files by adding this line of code in your wp-config.php file:
// Replace fr_FR with your language and country code. define ('WPLANG', 'fr_FR');
Note that after WP 4.0 you may select your default language during the installation procedure or under Settings > General admin screen.
Are you working on a child theme?
Those working with child themes ( kudos to you ), will already have a question in their minds…and the answer is YES! If you translate the PO/MO files on your parent theme, you will lose it on the next theme update. Relax, you may implement your translations on the child theme as well. Just follow the following instructions:
- Copy /languages folder from your parent to the child theme directory.
- On child theme, rename the files with .po/.mo extensions according to your locale ( ie. de_DE.po / de_De.mo for German installations )
- ONLY FOR CLEANSTART WP: Put this code to your child theme’s functions.php:
add_action('after_setup_theme','plethora_child_translation'); function plethora_child_translation() { load_child_theme_textdomain( 'cleanstart', get_stylesheet_directory() . '/languages' ); }
- Work with your PO/MO/POT files as referenced above in order to translate your website.