OpenSolaris Localization Work with PO Files
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:
# The following lines are contents of SUNW_OST_OSCMD/SUNW_ISCSI.po
# Messages from iscsitgtd/iscsitgtd.po
# msgstr
msgid "Operation completed successfully"
msgstr ""
The example of the Czech translation:
# The following lines are contents of SUNW_OST_OSCMD/SUNW_ISCSI.po # Messages from iscsitgtd/iscsitgtd.po # msgstr msgid "Operation completed successfully" msgstr "Operace byla úspěšně dokončena"
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.
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. Use the i18n-l10n component - Issues relating to internationalization and localization such as missing, incomplete or garbled translation, national keyboard input, fonts, locale data or unicode conversions issues. 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 "&Přidat"
or
msgid "_Add" msgstr "_Přidat"
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
All variables consist of % and one number or letter. Example of string with variable:
msgid "Automatic configuration via %s?"
msgstr ""
msgid "cannot open file: %s\n"
msgstr "soubor nelze otevřít: %s\n"
Variables are obligatory in your translation. If a string contains a variable, you have to use it in your translation too.
Formating Strings
In every po file you can find various formating strings. Most of them are same as HTML tags. It can also happens, you find XML tags or formating strings from other languages.
All these strings are obligatory in your translation. If you omit a string, the translation will not pass the syntax check.
| \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 |
| <b>some_text</b> | bold text | |
| <i>some_text</i> | italic text | |
| %d | decimal number | |
| %f | floating-point number |
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 (Slovak):
msgid "%1 second" msgid_plural "%1 seconds" msgstr[0] "%1 sekunda" msgstr[1] "%1 sekundy" msgstr[2] "%1 sekúnd"
In some translation tools you should first setup the plural forms definition in the project settings.
Syntax Checking
Before you commit the PO file to the Mercurial repository, check the syntax of the PO file. To do it, use
msgfmt -c any.po
or check functionality in your translation application.
If you don't have write access to the Mercurial repository, send your translated PO file to your team leader.