OpenSUSE Localization Abaout PO Files
İçindekiler
What is PO File
Dialogs and menus of an application, which should be translated, are stored in the PO file. The PO file is a file with special structure and suffix .po. It contains information about the language, translators, original dialogs and translated dialogs. Original dialogs starts with msgid and they are followed by their translation started with msgstr. Information about language and translator are at the beginning of the PO file. If no translated dialog or menus is available, the msgstr part is empty. The sign # means, that the line is a comment.
The example of the empty translation:
#: src/PackageCommands.cs:57 src/PackageCommands.cs:3181 msgid "Search for a match to any of the search strings" msgstr ""
The example of the Czech translation:
#: src/PackageCommands.cs:57 src/PackageCommands.cs:3181 msgid "Search for a match to any of the search strings" msgstr "Vyhledat výsledek odpovídající alespoň některému z řetězců"
What is POT File
The POT file is a template for the translation. The format of the POT file is similar to PO file but it includes only original English text and no information about language or translators. From the POT file are created PO files. If your created PO file manually in a text editor, you need add information about your language and save the file with suffix .po. If you create the beginning of the PO file incorrectly, the PO file will not pass the syntax check and in the statistics will have violet color and zero translated and fuzzy strings.
The beginning of the rug.pot:
# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2006-05-02 20:04-0400\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=CHARSET\n" "Content-Transfer-Encoding: 8bit\n"
The beginning of the rug.hu.po:
# translation of hu.po to # Peter Breuer <comp@suselinux.hu>, 2003. # Marcel Hilzinger <hili@suselinux.hu>, 2003. # Marcel Hilzinger <marcel.hilzinger@suselinux.hu>, 2004. # Szabolcs Varga <shirokuma@shirokuma.hu>, 2004, 2005. # Kalman Kemenczy <kkemenczy@novell.com>, 2006. msgid "" msgstr "" "Project-Id-Version: hu\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2006-06-08 12:58+0200\n" "PO-Revision-Date: 2006-06-08 17:26+0200\n" "Last-Translator: \n" "Language-Team: <hu@li.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.2\n" "Plural-Forms: nplurals=1; plural=0;\n"
How to Translate PO Files
All you need to start localization is a text editor and fill all empty msgstr with your translations. But maybe you find a special translation tool more convenient to do it.
Original English text in the PO file started with msgid is not possible to change. You can change only translation. If you find an error in the original English text, please use Bugzilla to report it. All wrong texts must be fixed in the source code of the application first and then will be generated a new POT file.
Shortcuts
There are two different ways how-to define shortcuts:
msgid "&Add..." msgstr "&Hozzáadás"
or
msgid "_Add" msgstr "_Hozzáadás"
You can select any letter of your translated string and also place the shortcut symbol to different position, but the shortcut symbol must be same as in the original strings. If it used & in the original string, you must also use the symbol & in your translation. If it is not possible to add shortcut directly to the string, use this syntax:
msgid "&Add..." msgstr "新增(&A)"
or
msgid "_Add" msgstr "新增(_A)"
Variables
Formating Strings
String | Meaning | Usage in the translation |
---|---|---|
\n | new line |
if all lines except the last in the original string end with \n you can have in your translation only the last line without \n even if you have in your translation more or less lines than in the original string. All other lines must end with \n. |
Plurals
String with a plural in a POT file:
msgid "%1 second" msgid_plural "%1 seconds" msgstr[0] "" msgstr[1] ""
Translation of the string with one plural form (zh_CN):
msgid "%1 second" msgid_plural "%1 seconds" msgstr[0] "%1 秒"
Translation of the string with two plural forms (Greek):
msgid "%1 second" msgid_plural "%1 seconds" msgstr[0] "%1 δευτερόλεπτο" msgstr[1] "%1 δευτερόλεπτα"
Translation of the string with three plural forms (Czech):
msgid "%1 second" msgid_plural "%1 seconds" msgstr[0] "%1 sekunda" msgstr[1] "%1 sekundy" msgstr[2] "%1 sekund"
In the KBabel you should first setup the plural forms definition in the project settings. If is your setting correct, KBabel will provide for each plural form separate tab.
Syntax Checking
Before committing the PO file to the SVN, check the syntax of the PO file. To do it, use msgfmt with parameter -c or check functionality in your translation application.