In this document:
As formulated in Wikipedia:
Note
The terms are frequently abbreviated to i18n and L10n respectively that reflect the length of the words.
In some cases, internationalization is simple. For example, making a US application accessible to Australian or British users may require a little more than a few spelling corrections. But to make a US application usable by Japanese users, or make a Korean application usable by German users, the software must operate not only different languages, but also use different input techniques and presentation conventions.
APS tries to make internationalization as painless as possible for developers.
The only supported charset is UTF-8. All data across APS framework is kept in its UTF-8 form, both in the input and output formats.
A locale name can define either a language only in the form ll, or language and country in the form ll_CC. Here are some sample locale name examples:
Name | Description |
---|---|
en | English |
en_US | English used in United States |
en_CA | English used in Canada |
de | German |
de_AT | German used in Austria |
… | … |
The language part is always written in lower case and the country part in upper case. The separator is underscore (“_”).
Browsers send the names of the languages they accept in the Accept-Language field of the HTTP header using the format generally defined by RFC 1766. Examples:
Code | Description |
---|---|
ar | Arabic |
en-au | English used in Australia |
en-ca | English used in Canada |
ar-aa | Arabic (Unitag) |
… | … |
Both, the language and the country parts are in lower case. The separator is a dash (“-“).
Translation string is a literal in a source file that can be translated. In some cases (JavaScript and HTML code), to make a string translatable, you have to add a hook to it. Such hooks tell the system: “This string should be translated into the end user’s language, if a translation for this string is available in that language.” It is the responsibility of the package developer to mark translation strings. The system can translate only those strings, for which it has translation to the required language.
A message file is a plain-text file, representing a single language that contains all available
translation strings and their interpretation (translation) in the given language.
Message file name has the .po
name extension.
This format is used by many known projects, for example:
Please refer to the Gettext Manual for more details.
A PO file is made up of many entries, each entry describes the relation between an original untranslated string and its corresponding translation:
For example:
msgid "Diskspace - Usage Only"
msgstr "Espacio en disco - Solamente Uso"
A typical PO file entry has the following schematic structure as defined at The Format of PO Files:
# translator-comments
#. extracted-comments
#: reference...
#, flag...
#| msgid previous-untranslated-string
msgid "untranslated-string"
msgstr "translated-string"
The #: comment contains reference to the translated lines in the source code.
Optionally, it is possible to define a plural form translations. For the additional msgid_plural string, the translator can create one or more msgstr plural translations, since in some languages the plural form may depend on the actual number of objects presented in a string as a parameter. For example, the following PO entry illustrates three possible translated messages in Russian:
msgid "Found __itemsCount__ item"
msgid_plural "Found __itemsCount__ items"
msgstr[0] "Найден __itemsCount__ элемент"
msgstr[1] "Найдено __itemsCount__ элемента"
msgstr[2] "Найдено __itemsCount__ элементов"
A PO file is composed of multiple PO entries whose layout (before the messages are translated) looks as follows:
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-06-08 10:12+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: actionlog/templates/object_action_list.html:7 txpermissions/forms.py:18
msgid "User"
msgstr ""
#: actionlog/templates/object_action_list.html:8
msgid "Action"
msgstr ""
#: foo/templates/bar.html:180
msgid "{0} result"
msgid_plural "{0} results"
msgstr[0] ""
msgstr[1] ""
The following text elements of APS applications are translation strings:
The aps msgmake
command extracts the translation strings into PO message files, one file per language.
This file is a convenient way for translators to provide the enterpretation of the translation strings in the target
language. This process relies on the GNU gettext toolset.
Once the translators have filled out the message files, the whole project must be compiled into the APS package. The APS functions and localization mechanism on the hosting management systems take care of translating the translation strings on the fly to available languages, according to users’ language preferences.
If you have completed all steps on making your package internationalized, its translation to a certain language requires additional steps as presented on the following chart:
Create the PO file in the i18n
folder by applying the aps msgmake
command to the package folder. For example,
to start localizing the VPScloud package into Spanish enter:
$ aps msgmake -l es_ES VPScloud
This will create the es_ES.po
file inside the i18n
folder.
Fill in the msgstr strings inside the es_ES.po
file in Spanish.
Build the package:
$ aps build VPScloud