How to Translate The Theme

Last Update: May 29, 2020

There are cases when we need to change the default texts of Phox across the front end of the website. Our subjects use the capabilities of the WordPress text field, so there is no need to change any core files to achieve this goal. To accomplish this, you need to know a few points.

Overview

Translate Theme – PO/MO files

WordPress uses 2 file pair with PO and MO extensions to understand where to put alternative texts inside code. PO file is a Key/Value pair file which will be used to add translations of specific phrases. MO file is compiled version of PO file which WordPress understands.

Phox also have their own PO/MO file pair that you can use to translate different parts of the theme. Those files are located in wp-content/themes/phox/languages folder.

How to edit PO files and Compile MO file out of it

You will need a software called POEDIT to edit PO files and add your translations inside that and generate MO file out of it. For more information please read this article in details:

  • Set Default Language. 
  • Install the Child Theme.  
  • Copy Languages Folder.  

Go to wp-content/themes/phox/languages and copy folder and paste it into your child theme wp-content/themes/phox-child So that you will have a folder on your child theme called languages:

You will see 2 files there that you can use for translation (en.mo and en.po). Please consider that the name of these 2 files should be the same as your default language code which you have set in wp-config.php file

  • Use Loco Translate.

The Loco Translate is a third party plugin which makes it possible to edit the PO files and compile them to MO files directly from the WordPress Admin section. Click here for more detailed information on how to use the plugin for the theme translation.

Setting Default Language of WordPress

Go to Settings > General > Default Language to see the option.