• LOGIN
  • No products in the cart.

30

May

2016

WordPress localization 101

Today it is a common practice to run websites in more than one language, targeting a wider geographical area, and audience. WordPress CMS natively¬† supports localization, but to make the website interface fully translated, the theme’s and plugins’ code has to provide the support as well.This article provides information on the WordPress localization.

If you use a quality written translation ready theme, then everything works smooth. Some themes need an extra touch to make translation working. Same thing happens when you want to modify the theme / plugin, or to correct the provided translation.

This series of articles will guide you through the important steps of Wodrpress website localization:

  1. Introduction to the structure of the WordPress translation.
  2. How to translate Wodpress themes and plugins.
  3. Theme’s original text strings customization.
  4. How to translate child themes.
  5. How to handle translations with plugins and theme updates.
  6. Adding a second language to a WordPress website.
  7. Adding translation support to WordPress themes and plugins.

The structure of the WordPress localization system

The WordPress translation system uses special localization files from the following folders:

wp-content/languages
wp-content/themes/your_theme/languages
wp-content/plugins/your_plugin/languages

The first folder is being used for the WordPress CMS localization, as well as for consolidation other translations. Two other folders is a part of your theme, and plugins.

There are two file types we can use from those folders: .pot, and .po.

.pot file is a language template file. It contains all the strings from the theme/plugin in original language, ready for translation. Basically this is the original file for all translation languages.

.po file is essentially a copy of the .pot file, which additionally has a translation of the original strings to one single language, as well as the information about that language.

Both of the files are essentially text files, in which each translation string are represented by a code block

#: theme_file.php:32
msgid "Original string"
msgstr "Translated string"

First line indicates the theme’s file (theme_file.php), and line number (32) in it, which contains the string for translation. This string is defined in the second line inside of the operator msgid (Original string). The translation itself is defined in the operator msgstr operator (Translated string), and only populated in .po files.

Luckily we do not need to handle those string manually. We’ll use a free tool to do it for us automatically, as you will find out in the next article. The only thing we have to care about is, are there translation files in the above mentioned folder, provided by the theme / plugin, or we have to create and populate them.

If translation if supported by the theme / plugin, then the language folder contains at least a .pot file.

If your language is supported by the theme / plugin, then the language folder also contains two additional files, ending like this:

ru_RU.po
ru_RU.mo

RU here is used as an example of a two letter language code (RU is the code for Russian language). First, low case ru is a language code, second, upper case RU is a code of the language dialect. Another example: en_US, and en_UK – for American English, and United Kingdom English.

.mo – file is a binary machine file automatically generated from the .po file for the site translation use. So, technically speaking, the theme / plugin provides .pot file, we create translations in .po file (if it’s not done by the theme / plugin author), and site will use the automatic .mo file. Everything else should work automatically, if not, read the last article in this series.

  1. Introduction to the structure of the WordPress translation.
  2. How to translate Wodpress themes and plugins.
  3. Theme’s original text strings customization.
  4. How to translate child themes.
  5. How to handle translations with plugins and theme updates.
  6. Adding a second language to a WordPress website.
  7. Adding translation support to WordPress themes and plugins.

In the next article we will go through the .pot file creation.

If you need more detailed information on the WordPress translation system, please check the official wordpress.org site translation area.



As usually, I’ll be glad to answer your questions, or provide more clarification on the topic of this article:

3 comments

    Leave a Reply

    © Isigma Photo. All rights reserved

    Login

    Register

    FACEBOOKGOOGLECreate an Account