Difference between revisions of "Localization"

From den4b Wiki
Jump to navigation Jump to search
(→‎Translation files: separate section for creating new translations, relevant PO headers)
Line 18: Line 18:
 
Template file (<tt>Application.po</tt>) is used for creating translations for new languages and normally should not be edited.
 
Template file (<tt>Application.po</tt>) is used for creating translations for new languages and normally should not be edited.
  
Translation files (<tt>Application.XX.po</tt>) contain translated text. A '''two-letter language codes''' in the file extension identifies a particular language.
+
Translation files (<tt>Application.XX.po</tt>) contain translated text. A '''two-letter language code''' in the file extension identifies a particular language.
* All possible language codes are defined in [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO 639-1] (not the same as two-letter country codes in [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2]).
+
 
 +
== Create new translations ==
  
 
To create a translation file for a new language:
 
To create a translation file for a new language:
 
# Create a copy of <tt>Application.po</tt> (template file)
 
# Create a copy of <tt>Application.po</tt> (template file)
 
# Rename it to <tt>Application.XX.po</tt> (translation file), where ''XX'' is a two-letter language code.
 
# Rename it to <tt>Application.XX.po</tt> (translation file), where ''XX'' is a two-letter language code.
# Edit new translation file using instructions below.
+
# Translate entries to the new langauge using instructions below.
 +
# Populate PO file headers, copy from any other translation file and modify appropriately.
 +
 
 +
Example of relevant entries in PO file headers for a new translation file:
 +
<pre><nowiki>
 +
msgid ""
 +
msgstr ""
 +
...
 +
"Language: ru\n"
 +
"X-Country: ru\n"
 +
"X-Country-Name: Russia\n"
 +
"X-Language-Name: Russian\n"
 +
"X-Translators: Your Name\n"
 +
...
 +
</nowiki></pre>
 +
 
 +
* Language codes are defined in [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO 639-1]
 +
* Country codes are defined in [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2].
  
 
== Editing translation file ==
 
== Editing translation file ==

Revision as of 22:02, 20 August 2014

This article describes localization (translation) of applications into different languages. Please study this material carefully before attempting to contribute.

Products which currently support this new method for localization are:

Note: Previous versions of localization articles are available for reference, but they should no longer be used: Localization Old 2013, Localization Old 2014.

Translation files

Translations are stored in PO files (as produced by gettext) are are distributed together with the application, inside Languages folder:

  • Languages\Application.poTemplate file.
  • Languages\Application.ru.poRussian (RU) translation file.
  • Languages\Application.es.poSpanish (ES) translation file.
  • Languages\Application.fr.poFrench (FR) translation file.
  • ...

Template file (Application.po) is used for creating translations for new languages and normally should not be edited.

Translation files (Application.XX.po) contain translated text. A two-letter language code in the file extension identifies a particular language.

Create new translations

To create a translation file for a new language:

  1. Create a copy of Application.po (template file)
  2. Rename it to Application.XX.po (translation file), where XX is a two-letter language code.
  3. Translate entries to the new langauge using instructions below.
  4. Populate PO file headers, copy from any other translation file and modify appropriately.

Example of relevant entries in PO file headers for a new translation file:

msgid ""
msgstr ""
...
"Language: ru\n"
"X-Country: ru\n"
"X-Country-Name: Russia\n"
"X-Language-Name: Russian\n"
"X-Translators: Your Name\n"
...

Editing translation file

The process involves translation of individual textual messages to create a mapping from original text to a different language.

Translation files (*.po) should be edited with specifically designed translation tools:

Notes for advanced users:

  • Translation files could also be edited manually using a text editor, but this is highly discouraged as tiny mistakes can result in corruption of the entire file.
  • Poedit forcefully wraps long entries causing "noise" in diffs, so PO files need to be cleaned via msgcat --no-wrap before committing. [1].

Guidelines for translators

Guidelines for translators:

  • Try not the exceed the length of the translated text, comparing to the length of the original text.
    Some components may not fit longer text, so it is better to make it shorter rather than longer.
  • Beware of the special formatting, symbols and placeholders, e.g. "\n", "%s", "%d".
    Make sure to maintain such formatting, translate only actual words.
  • If you don't have a good translation for some text, just leave those blank.
    Other people may be able to fill in the blanks later.

Attribution to the translator:

  • Replace "#Translator#" value with your name and it will be displayed in the About dialog of the translated application.
  • If you are updating an existing translation, please keep the name of original author and append your name if you wish (comma separated).

Loading specific language

Application automatically tries to recognize system language on launch and loads appropriate translation file.

To load a specific language (translation) file, either:

  • Add "--lang XX" command line parameters to the application, where XX is a two-letter language code.
  • Set "LANG" environmental variable to a two-letter language code.

Publishing your translation

Please send new and updated translation files via email, as attachments.

The email address can be found in the About dialog of every application.