Difference between revisions of "Localization"

From den4b Wiki
Jump to navigation Jump to search
(Created page with "This article describes localization (translation) of the software into different languages. Please study this material carefully before attempting to contribute. Note: Previo...")
 
Line 7: Line 7:
 
Translations are stored in '''PO files''' (as produced by [http://en.wikipedia.org/wiki/Gettext gettext]) are are distributed together with the application, inside '''Languages''' folder:
 
Translations are stored in '''PO files''' (as produced by [http://en.wikipedia.org/wiki/Gettext gettext]) are are distributed together with the application, inside '''Languages''' folder:
  
* <tt>Languages\Application.po</tt> - '''Template''' file.
+
* <tt>Languages\Application.po</tt> &ndash; '''Template''' file.
* <tt>Languages\Application.ru.po</tt> - '''Russian''' (RU) translation file.
+
* <tt>Languages\Application.ru.po</tt> &ndash; '''Russian''' (RU) translation file.
* <tt>Languages\Application.es.po</tt> - '''Spanish''' (ES) translation file.
+
* <tt>Languages\Application.es.po</tt> &ndash; '''Spanish''' (ES) translation file.
* <tt>Languages\Application.fr.po</tt> - '''French''' (FR) translation file.
+
* <tt>Languages\Application.fr.po</tt> &ndash; '''French''' (FR) translation file.
 
* ...
 
* ...
  
Files in a form of <tt>Application.XX.po</tt> contain a '''two letter country codes''' in the file extension. Country codes are defined by [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2].
+
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 country codes''' in the file extension to identify a particular language. All possible country codes are defined in [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2].
  
 
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> and rename it to <tt>Application.XX.po</tt>
+
# Create a copy of <tt>Application.po</tt> (template file)
*: Where '''XX''' is a two letter country code for the language for which you are making a translation.
+
# Rename it to <tt>Application.XX.po</tt> (translation file), where ''XX'' is a two-letter country code for the new language.
 +
# Edit new translation file using instructions below.
  
 
== Editing translation file ==
 
== Editing translation file ==
Line 23: Line 26:
 
The process involves translation of individual textual messages to create a mapping from original text to a different language.
 
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:
 +
* [http://virtaal.translatehouse.org/ Virtaal] &ndash; preferred editor.
 +
* [http://poedit.net/ Poedit] &ndash; alternative editor. Its use if discouraged because it changes the formatting of the file and results in large diff's.
 +
 
 +
Note: 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.
  
 
== Loading specific language ==  
 
== Loading specific language ==  
Line 31: Line 38:
 
To load a specific language (translation) file, either:
 
To load a specific language (translation) file, either:
 
* Set "<tt>LANG</tt>" environmental variable to a two-letter language code.
 
* Set "<tt>LANG</tt>" environmental variable to a two-letter language code.
* Add "<tt>--lang XX</tt>" command line parameters to the application, where XX is a two-letter language code.
+
* Add "<tt>--lang XX</tt>" command line parameters to the application, where ''XX'' is a two-letter language code.

Revision as of 23:00, 9 August 2014

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

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

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 country codes in the file extension to identify a particular language. All possible country codes are defined in ISO 3166-1 alpha-2.

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 country code for the new language.
  3. Edit new translation file using instructions below.

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:

  • Virtaal – preferred editor.
  • Poedit – alternative editor. Its use if discouraged because it changes the formatting of the file and results in large diff's.

Note: 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.

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:

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