Difference between revisions of "Localization"

From den4b Wiki
Jump to navigation Jump to search
(→‎Loading specific language: changes for the new Languages menu and Autodetect mode)
(Removed "more will be added soon")
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This article describes localization (translation) of applications into different languages. Please study this material carefully before attempting to contribute.
 
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:
+
Products which currently support this new method of localization:
* [[ReNamer]]
+
* [[ReNamer]] (since v6.0.0.1)
* (more will be added soon)
+
* [[Hasher]] (since v3.1.0.1)
 +
* [[Colors]] (since v2.0.0.1)
 +
* [[Resizer]] (since v1.0.0.0)
 +
* [[RandPass]] (since v1.4.0.0)
 +
* [[Shutter]] (since v4.0.0.1)
  
Note: Previous versions of localization articles are available for reference, but they should no longer be used: [[Localization Old 2013]], [[Localization Old 2014]].
+
<small>Note: Previous versions of localization articles are available for reference, but they should no longer be used: [[Localization Old 2013]], [[Localization Old 2014]].</small>
  
 
== Translation files ==
 
== Translation files ==
  
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]) which are distributed together with the application, inside '''Languages''' folder:
 
* <tt>Languages\Application.po</tt> &ndash; '''Template''' file.
 
* <tt>Languages\Application.po</tt> &ndash; '''Template''' file.
 
* <tt>Languages\Application.ru.po</tt> &ndash; '''Russian''' (RU) translation file.
 
* <tt>Languages\Application.ru.po</tt> &ndash; '''Russian''' (RU) translation file.
Line 27: Line 31:
 
# Translate entries to the new langauge 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.
 
# Populate PO file headers, copy from any other translation file and modify appropriately.
 +
# Save new file using UTF-8 encoding, without byte order mark ([https://en.wikipedia.org/wiki/Byte_order_mark BOM]).
  
 
Example of relevant entries in PO file headers for a new translation file:
 
Example of relevant entries in PO file headers for a new translation file:
Line 37: Line 42:
 
"X-Country-Name: Russia\n"
 
"X-Country-Name: Russia\n"
 
"X-Language-Name: Russian\n"
 
"X-Language-Name: Russian\n"
"X-Translators: Your Name\n"
+
"X-Language-Name-Native: Русский\n"
 +
"X-Translators: Your Name <your.email@example.com>\n"
 
...
 
...
 
</nowiki></pre>
 
</nowiki></pre>
Line 43: Line 49:
 
* Language codes are defined in [http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes ISO 639-1]
 
* 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].
 
* Country codes are defined in [http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2].
 +
* In conflicting and ambiguous situations:
 +
*# Name the translation file using <tt>Application.XX_YY.po</tt> format, where ''XX'' is a language code and ''YY'' is a country code.
 +
*# Set <tt>X-Language-Name</tt> header to highlight the difference between translations.
 +
*: For example: "<tt>en_US</tt>" code for ''English (United States)'', "<tt>en_GB</tt>" code for ''English (United Kingdom)''.
  
 
== Editing translation file ==
 
== Editing translation file ==
Line 48: Line 58:
 
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:
+
Translation files (*.po) should be edited with specifically designed translation tools, such as:
* [http://poedit.net/ Poedit] &ndash; Editor for Windows, Linux and Mac.
+
* [http://poedit.net/ Poedit] &ndash; for Windows, Linux and Mac.
* [http://virtaal.translatehouse.org/ Virtaal] &ndash; Editor for Windows, Linux and Mac.
 
* [http://github.com/mlocati/betterpoeditor/releases Better PO Editor] - Editor for Windows only.
 
  
 
Notes for advanced users:
 
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.
 
* 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.
* [http://poedit.net/ Poedit] forcefully wraps long entries causing "noise" in diffs, so PO files need to be cleaned via <code>msgcat --no-wrap</code> before committing. [http://github.com/vslavik/poedit/issues/94].
+
* [http://poedit.net/ Poedit] versions prior to 1.7 forcefully wrap long entries causing "noise" in diffs, so PO files need to be cleaned via <code>msgcat --no-wrap</code> before committing. [http://github.com/vslavik/poedit/issues/94].
  
 
== Guidelines for translators ==
 
== Guidelines for translators ==
  
 
Guidelines for translators:
 
Guidelines for translators:
 +
* Use the most up-to-date language files from the <u>latest development version</u> (Beta versions).
 
* Try not the exceed the length of the translated text, comparing to the length of the original text.
 
* 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.  
 
*: Some components may not fit longer text, so it is better to make it shorter rather than longer.  
Line 66: Line 75:
 
* If you don't have a good translation for some text, just leave those blank.
 
* 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.
 
*: Other people may be able to fill in the blanks later.
 +
* Try to use formal but easy to understand language.
 +
*: Avoid the use of slang, which may not be understood by some readers.
  
Attribution to the translator:
+
Attribution to translators:
* Replace "''#Translator#''" value with your name and it will be displayed in the ''About'' dialog of the translated application.
+
* Add your name to "<tt>X-Translators:</tt>" field in PO file headers.
* If you are updating an existing translation, please keep the name of original author and append your name if you wish (comma separated).
+
* Please keep names of other translators (separate multiple names with a comma).
 +
 
 +
== Auxiliary translation files ==
 +
 
 +
In addition to the main translation file, you may find auxiliary translation files in subfolders. These correspond to 3rd party components, for example, "LCLStrConsts" subfolder contains messages that appear in Lazarus Component Library (LCL). We do not handle the updates to auxiliary translation files directly, because we source that from the original vendor. If you wish, you can submit your improvements directly to the vendor.
 +
 
 +
Updates for "LCLStrConsts" translations should submitted to the [https://www.lazarus-ide.org/ Lazarus IDE] project, using the following steps:
 +
 
 +
# The translation should be based on the latest development version (SVN TRUNK)
 +
#: https://svn.freepascal.org/svn/lazarus/trunk/lcl/languages/
 +
# The translation file can be submitted via the bug tracker (under "Lazarus" project)
 +
#: https://bugs.freepascal.org/bug_report_page.php
  
 
== Loading specific language ==  
 
== Loading specific language ==  

Revision as of 15:12, 4 April 2020

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 of localization:

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) which 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.
  5. Save new file using UTF-8 encoding, without byte order mark (BOM).

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-Language-Name-Native: Русский\n"
"X-Translators: Your Name <your.email@example.com>\n"
...
  • Language codes are defined in ISO 639-1
  • Country codes are defined in ISO 3166-1 alpha-2.
  • In conflicting and ambiguous situations:
    1. Name the translation file using Application.XX_YY.po format, where XX is a language code and YY is a country code.
    2. Set X-Language-Name header to highlight the difference between translations.
    For example: "en_US" code for English (United States), "en_GB" code for English (United Kingdom).

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, such as:

  • Poedit – for Windows, Linux and Mac.

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 versions prior to 1.7 forcefully wrap 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:

  • Use the most up-to-date language files from the latest development version (Beta versions).
  • 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.
  • Try to use formal but easy to understand language.
    Avoid the use of slang, which may not be understood by some readers.

Attribution to translators:

  • Add your name to "X-Translators:" field in PO file headers.
  • Please keep names of other translators (separate multiple names with a comma).

Auxiliary translation files

In addition to the main translation file, you may find auxiliary translation files in subfolders. These correspond to 3rd party components, for example, "LCLStrConsts" subfolder contains messages that appear in Lazarus Component Library (LCL). We do not handle the updates to auxiliary translation files directly, because we source that from the original vendor. If you wish, you can submit your improvements directly to the vendor.

Updates for "LCLStrConsts" translations should submitted to the Lazarus IDE project, using the following steps:

  1. The translation should be based on the latest development version (SVN TRUNK)
    https://svn.freepascal.org/svn/lazarus/trunk/lcl/languages/
  2. The translation file can be submitted via the bug tracker (under "Lazarus" project)
    https://bugs.freepascal.org/bug_report_page.php

Loading specific language

All available language files are automatically added to the "Languages" menu on startup. Select a desired language and restart the application.

When selected language is set to "Autodetect" mode:

  • Application automatically tries to recognize system language and loads appropriate translation file.
  • It is also possible to load a specific language file, by either:
    1. Adding "--lang XX" command line parameters to the application, where XX is a two-letter language code.
    2. Setting "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.