Chapter 9. Internationalization and Localization

oct 31 = dec 25

A mathematical joke

In this chapter, we will provide a brief overview of:

  • The internationalization capabilities of eZ Publish, and will implement some additional language translations for our customers who may be visiting and looking to enroll themselves in the magazine
  • How to use the eZ Publish backend to translate articles and content classes, and then publish them

A multilingual site

Internationalization and localization are two big issues for people who need to develop a multilingual site. Other than the simple text translation, a developer needs to know how the local standard formats—such as dates, numbers, or amounts—change from country to country. Internationalization and localization take care of these problems.

Internationalization

Internationalization, often referred to as i18n (the number represents the count of the letters in the word), is the practice of creating software so that it isn't hard-wired to one language, locale, or culture.

For example, the workflow of a contact form will work in the same way even if the page contains English or Italian text.

Fortunately, eZ Publish allows the implementation of internationalization for any single object that it can manage. This will help us in translating language templates, content objects, attributes, and much more.

Localization

The localization process (L10n) helps site administrators to assign the correct values according to the country language displayed. This means that you not only show the translated text, but also dates in the appropriate format based on the languages used. For example, in the English interface, a date is based on the month/day/year format, whereas in the Italian interface, a date is represented in the day/month/year format.

To manage the country-specific settings, eZ Publish uses the locale identifier.

Locale identifiers

A locale identifier consists of a language code of three letters (ita), followed by two uppercase letters (IT) for the country code. This identifier is based on the ISO 639 (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=22109http://it.wikipedia.org/wiki/ISO_639) and ISO 3166-1 (http://it.wikipedia.org/wiki/ISO_3166-1) standards.

eZ Publish uses the default locale, the United Kingdom English language (eng-GB), and has a lot of pre-defined locale settings in the .ini file located in the share/locale directory of the installation root.

Creating a new locale file

eZ Publish has a lot of default locale settings. However, a specific behavior or language may not be provided. To create a new locale, we should copy one of the standard files provided in the share/locale folder and overwrite it with the necessary content. We can also send our job to the contributions page (http://ez.no/developer/contribs/internationalization) at the ez.no site. From the same site, we can also download a lot of updated locale files.

As an example, if we need to create a Klingonian locale file based on English language, we have to open a shell to create the new file in this way:

# cp share/locale/eng-GB.ini share/locale/kln-KL.ini

Next, we will edit the new kln-KL.ini file by adding the country's locale settings.

After we create the locale file, we also have to create a translation file for the eZ Publish main interface. We can find translation files in the share/translations directory, placed in the root of the system.

As we can see, this folder contains a set of subfolders named with the locale identifier (such as, ita-IT). These subfolders contain a translation.ts XML file that can be used to translate the localization strings from the default eZ Publish English to the locale language.

eZ Publish has, by default, an untranslated folder that can be used as a template for creating a new, clean translation file. To create our translation file for the new locale, we have to execute the following command from the eZ Publish installation path:

# cp -Rf share/translations/untraslated/ share/translations/kln-KL

Now, we can easily translate the file's entries by using software such as QtLinguist (http://www.qtsoftware.com/products/developer-tools).

Tip

You can find more information on this software application in the QTLinguist manual on the QT technical documentation site: http://doc.trolltech.com/4.5/linguist-manual.html.

Anatomy of the translations.ts file

The translations.ts file is an XML file that contains information on how to translate a particular string.

The structure of the file is based on a context tag, which contains a unique identifier called name, a message tag with the original text source, and the relative translation file. As an example, the following is an extract from the eZ Webin translation.ts file:

<context>
<name>design/ezwebin/article/article_index</name>
<message>
<source>Article index</source>
<translation>Indice articolo</translation>
</message>
</context>

Tip

Note that the translations.ts file should be encoded with UTF8 so that it can be opened with QtLinguist.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.186.153