Knowlegde Base

How to translate the entire theme/ several text strings to another language

In this section, you will find all basic steps to translate the theme to the language you want. Please remember that theme and plugin need to be translated separately. We recommend you to download and install Poedit – a third party tool for your translation.

The below method can be applied for:

  • Translating several default texts or “strings” to your own text. This includes modifying English terms and replacing them with your own English terms (e.g: Hotel -> Accommodation, Customers -> Clients and so on)
  • Translating the entire theme to another language

NOTICE – For fully theme translation, please take note that you must translate both of the theme and plugin.

 

  1. Define the language

In order to make WordPress recognize the language to which you want to translate, you have to define the language within the wp-config.php file

  • Login to your FTP account and edit the wp-config.php file
  • In the wp-config.php file, look for define(‘WPLANG’, ”);

If the constant is not available in the wp-config.php file, please add it as a new line anywhere.

  • Define the WPLANG constructor by adding the ISO Language code of your language. First 2 characters of a language code define the Language, the last 2 characters define the Country.

e.g : If you want to translate to Portuguese spoken in Brazil :define(‘WPLANG’, “pt_BR”)

 

2. Localize the translation file

XXX.pot (XXX is the theme name) is a file listing all the text strings used, which are in English and can contain a translation for each text string. XXX.pot can be found at:

  • For theme translation: wp-content/themes/languages
  • For plugin translation: wp-content/plugins/solazu-unyson/framework/languages

To get ready for your translation, please create a .po file in the Languages folder by:

  • Open XXX.po by Poedit

Select Create new translation and choose your Language of the translation

 

After you finish translating, save the file and you will see 2 new files

  • .po file: contains the strings and the translation you had already translated. If you need to translate more words, you can open this file to edit it
  • .mo file: a non-readable file used by WordPress

 

NOTICE

  • .mo file name must be xx_XX.mo (e.g : pt_BR.mo)
  • .po file name must be pluginname-xx_XX.po (e.g: solazu-unyson-xx_XX.mo)

 

3. Translation process

When open .po file in Poedit, The English text strings are displayed in the left column called Source text. When you add translations, they will show up in the right column – Translation.

  • Select the text line you want to translate and enter translated text into Translation section. You can type your own translated text or just simply use 1 of the options in Translation suggestion.
  • After you have done your translation, click Save to save changes.
  • In WP admin panel, Settings > General > Site Language and choose your desired language.
  • Go back and navigate to Settings > Permalinks > Save to apply changes

 

NOTICE:

  • If the text you want to translate can’t be found in the theme source, please find it in the plugin source
  • Follow the above instruction to make sure your translation will not get lost when updating theme because the wp-content folder will not be overwritten.

Leave your comment

Please enter your name.
Please enter comment.