|
Traslate Toolkit
Reference documentation
For information about the tools of the Translate Toolkit, please visit http://translate.sourceforge.net/
Javier Solá, David Fraser and Dwayne Bailey
Applies to Translate Toolkit version 0.8rc2. Last changed on 10/03/2005
The Translate Toolkit is a set of tools designed to standardise translation of Open Source applications. It permits translating quite a number of Open Source applications using the same translation tools.
It simplifies and facilitate the translation of some of the key end-user OpenSource applications: the OpenOffice application suite and applications belonging to the Mozilla family (Mozilla suite, Firefox, Thunderbird, etc.).
In all these applications, the messages that need to be translated to the target language are in specific files (each one with its own format). This Toolkit converts these files into a standard format (PO format) that is normally used for translation. The advantage of this conversion is that there are special editors to translate PO files, making the work of the translators very easy, seeing the original and the translation at the same time, knowing how much work has been done, saving all messages in a database (translation memory) that can be used in other files, etc. Once the files have been translated by the translators, tools in the Toolkit are used again to pack the translated files into a format that Mozilla or OpenOffice can understand.
For localization teams the most important advantage is that anybody doing translation only needs to learn how to use a simple PO file editor (such as poEdit or kBabel), and not a different tool and methodology for each application. PO editors tend to work well with all character sets, including Unicode, and some of them (poEdit, and reportedly now kBabel) work in both the Windows and Linux platforms, not forcing translators to use a specific platform for translation.
The tools are divided in three blocks: OpenOffice tools, Mozilla tools and generic support tools.
The Mozilla tools are formed by two programs:
The equivalent programs for OpenOffice are:
Upgrade tool for both Mozilla and openOffice:
PO 2 Xliff and viceversa transformation
Support tools are:
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla type files which contain translatable messages (.dtd and .properties files) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla can understand (a XPI Language Pack). They can be used with any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
The moz2po program unpacks an original Mozilla Language pack (a file with the .xpi extension) into a directory, converting the translatable (.dtd and .properties) files into equivalent standard PO files, while also making available to the translator other files that require changes (in order to localize the Language pack).
As input it takes a Mozilla American English Language Pack. This Language pack is a .XPI file (a zip format compressed file that includes all the files that need to be translated or localized).
As output it produces a whole new tree (a folder with subfolders inside) that contains all the files from the original Language pack (except for .dtd and .properties files, which have been translated to PO format). The folder produced contains the following subfolders:
moz2po can also be used to convert to PO format a language pack that is already translated. As the language pack for your language does not have the English original messages (needed for the PO file), it also needs to use an original English language pack (en-US.xpi) as a template, so that it will have all the information needed for the PO files. This conversion (to PO format) permits the use of the information contained in the Mozilla files with a Translation Memory tool that uses PO files as input.
moz2po other use is to convert any tree of files that includes .dtd files and .properties files into another tree with identical structure that includes all the same files of the original tree, except that all these .dtd and .properties files are converted to PO files with the same name and with the to .dtd.po and .properties.po extensions.
This last application is useful for the new localization packs used in Mozilla products for CVS based localization. The Mozilla Foundation produces ZIP files that include a tree of files identical to the tree used for localization of a given language in the Mozilla-product CVS. Once localized, this packaged can be directly uploaded to CVS, and the Mozilla Foundation will produce the local language executable packages, as well as the installers.
This function must be used only once, before starting the translations. If it is used again once some of the PO files have been translated, it will overwrite the translated files with empty PO files, having to start the translation again.
Note: the format of the generated PO files is UTF-8, which allows this files to be translated to any language that uses Unicode. When translated back to ,dtd and .properties formats, .dtd files are generated in UTF-8 format, and .properties files in Escaped Unicode format, as required by Mozilla applications.
Different syntax is given for the different uses of the program:
Conversion of an original English XPI file into a tree of .po files and other localizable files
usage: moz2po [options] INPUT OUTPUT
Examples:
moz2po –i en-US.xpi –o locale
This command creates - based on the en-US.xpi original English pack - the tree described above under the locale name, containing the structure of the package (in the locale\package subfolder), a copy of the en-US.xpi file in the locale\template sub-folder (to be used for repackaging), and other subfolders that contain PO files that need to be translated and other files which might need to be localised (locale\reg, locale\lang-reg, locale\win, etc.).
Conversion (migration) of an already translated language pack into a PO files and other localized files
usage: moz2po [options] -i INPUT -o OUTPUT –t TEMPLATE
Example:
moz2po -i km-KH.xpi -o locale -t en-US.xpi This program takes the Khmer language pack for a Mozilla application (km-KH.xpi) and the original US English language pack for the same application (and version, en-US.xpi) and creates a directory of PO files that have in the original string (msgid) the English original and in the translation string (msgstr) the Khmer translation. This command creates - based on the km-KH.xpi file (an XPI language pack for Khmer language) and the en-US.xpi original English pack - the tree described above under the locale name, containing the structure of the km-KH.xpi package (in the locale\package subfolder), a copy of the en-US.xpi file in the locale\template sub-folder (to be used for repackaging), and other subfolders that contain PO files that already contain the translated strings from km-KH.xpi and other files which have already been localised in km-KH.xpi (such as contents.rdf files) These directories are named locale\reg, locale\lang-reg, locale\win, etc. Conversion a tree that contains .dtd. and .properties files into a similar tree in which these files are turned into PO files. usage: moz2po [options] INPUT OUTPUT
Example:
moz2po –i EnglishTree –o localeTree
This instruction copies all the EnglishTree folder and its contents into localeTree, maintaining the subfolder structure. All files are copied to the second tree, except for .dtd and .properties files, which are replaced in the localeTree folder by their equivalent PO files with extensions .dtd.po and .properties.po
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla type files which contain translatable messages (.dtd and .properties) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla can understand (a XPI Language Pack). IT can be used with any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
Once the user has created a tree of localizable files using moz2po, and translated and localized everything that was required, po2moz takes all this tree again and converts it to a Language pack for your language.
The name of the locale of a language pack is used often inside the language pack. This name (<LanguageCode-RegionCode>, as en-US, km-KH, af-ZA, etc.) is passed to po2moz as an argument, and po2moz takes care of inserting it in file names or folder names in the destination pack when this is necessary.
po2moz can also be used to convert any tree of files that includes .dtd.po files and .properties.po files to another identical tree that includes the all the same files of the original tree, except that all these PO files are converted to .dtd and .properties files. This is useful for the new localization packs used in Mozilla products for CVS based localization. The Mozilla Foundation produces ZIP files that include o tree of files identical to the tree used for localization of a given language in the Mozilla-product CVS. The tree in these packs is converted to a tree that contains PO files using the moz2po tool, and after translation and localization, the tree is converted again with po2moz into a tree that contains translated .dtd and .properties files... and which can be uploaded directly into CVS.
In order to assure that all the original information from the original .dtd or .properties files is put into the newly generated file, it uses as templates the original .dtd and .properties files that are in the original folder from which the .po files where generated. Files in the target directory are re-written if the program is run more than once, but this does not have any side-effects, as the files are generated always from the PO files.
Note: PO files include the “&” character to specify that a given shortcut can be used (it does not always indicate this, when it followed by a word and a semicolon it indicates a variable name). The “&” indicates that the next character can be used as a shortcut. This shortcut character can be changed when editing to PO file, and a different character can be used for the short. If the “&” character is not present in the translation, po2moz will automatically include the old shortcut in the final .dtd file.
Different syntax is given for the different uses of the program:
Creation of an XPI file from localized PO files:
usage: po2moz [options]-i INPUT -o OUTPUT -l LOCALE
Example:
po2moz -x CVS -x '*.diff" -i locale -o firefox1.0RC.km-KH.xpi -l km-KH
It takes the (already created with moz2po and translated) PO files contained in the locale directory, converts them to the original .dtd and .properties formats and with them it creates a language pack called firefox1.0RC.km-KH.xpi for the target language. In this package, locale sensible file names and directory names use KH as the region name and km-KH as the full locale name when needed. Do not include in the XPI files and directories called CVS, nor files with the "diff" extension. Creation of a tree that contains translated .dtd. and .property files from localized PO files:
usage: po2moz [options] -i INPUT -o OUTPUT -t TEMPLATE
Example:
po2moz -i locale -o firefox1.0RC-kmKH -t firefox1.0RC-enUS
It takes the (already translated) PO files contained in the locale directory, converts them to the original .dtd and .properties formats (with the help of the files contained in the original firefox1.0RC-enUS folder) and creates a new folder called firefox1.0RC-kmKH, identical in structure to locale and to firefox1.0RC-enUS folders, in which instead of PO files there are translated .dtd and .properties files.
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla and OpenOffice type files which contain translatable messages (.dtd, .properties or GSI files) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla or OpenOffice can understand (a XPI Language Pack or a GSI file). The Toolkit can be used for OpenOffice or for any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
The oo2po program converts an OpenOffice GSI file (a file that contains all the messages used by OpenOffice) into a set of manageable POT files (PO templates, empty PO files) that can be easily used by translators, even distributed among several traslators (which would not be the case if only one large PO file had been created). These files are stored in a tree of folders. Once they have been translated, the po2oo tool can be used to convert the files back to GSI format, the format accepted by the OpenOffice project. It is nevertheless advisable to run pofilter before you convert back, to make sure that your files do not have any outstanding problems.
The oo2po utility has now been integrated in the OpenOffice build process. PO files for each version of OOo are produced directly by OpenOffice.org. This means that you (as a localizer) will normally not need to run this program.
As input, oo2po takes the GSi file corresponding to the version of OpenOffice that you wish to translate. If you are creating POT files, the GSI files only need to contain the English language. Nevertheless, it is also possible to have POT files in which the reference language used in the msgid fields of the PO files is other than English. In order to do this, it is necessary to have a GSI file that includes the language that you want to use as reference. This is very useful for countries in which the second language is French, Russian or some language other than English.
As output it produces a whole new tree (a folder with subfolders inside) that contains one POT file for each part of OpenOffice.
oo2po can also be used to convert to PO format GSI files that are already totally or partially translated to your language. In order to do this, you need to have a GSI file that has -at least- English and your language. oo2po will create files that have the original language as msgid and your languages in the msgstr.
In this second case, this function must be used only once, before starting the translations. If it is used again once some of the PO files have been translated, it will overwrite the PO files that you have worked on with PO files created again fom the GSI, having to start the translation again.
Note: the format of the generated PO files is UTF-8, which allows this files to be translated to any language that uses Unicode.
As in the case of generating POT files, oo2po also permits using here as reference a language (in the msgid) different from English. For this it is necessary to have a GSI file that includes both the language that will be used as reference in the msgid and the target language that will be placed in the msgstr fields.
Conversion of an original English GSI file into a tree of .po files
usage: oo2po [options] -P INPUT OUTPUT
Examples:
moz2po -P en_US.sdf locale
This command creates - based on the en_US.sdf original English GSI file - a folder called locale with subfolders that contain all the POT (PO template) files needed by that version of OpenOffice, including helpfiles. These POT files are empty PO files that need to have their extension changed to .po when their transaltion start.
oz2po -P en_US_and_French.sdf locale --source-language=fr_FR
This command creates - based on the en_US_and_french.sdf GSI file (which contains at least the English and French messages) - a folder called locale with subfolders that contain all the POT (PO template) files needed by that version of OpenOffice, including helpfiles. These POT files are empty PO files that need to have their extension changed to .po when their transaltion start. As reference language in the msgid fields it has French French (fr_FR), as spoken in France itself!!
Conversion of an GSI file that has English (or other reference language) and -at least- another language into a tree of .po files that have all the available translations to that second language.
usage: oo2po [options] -i INPUT -o OUTPUT -l LOCALE_CODE [--source-language=ISO]
Example:
oo2po -i en_US_and_km.sdf -o locale -l km
This command creates - based on a GSi file that contains the original English and Khmer (partial or complete) translation (en_US_and_km.sdf) - a folder called locale with subfolders that contain all the PO files needed by that version of OpenOffice, including helpfiles. These PO files contain the original English in the msgid string and translations to Khmer (km) in the msgstr for the strings that it is available. Other strings are empty.
oo2po -i en_US_and_pt_PT_some_pt_BR.sdf -o locale -l pt_BR --source-language=pt_PT
This command creates - based on a GSi file that contains the original English and Portuguese Portuguese (complete) translations, as well as some Brazilian Portuguese (en_US_and_pt_PT_some_pt_BR.sdf) - a folder called locale with subfolders that contain all the PO files needed by that version of OpenOffice, including helpfiles. These PO files contain the original Portuguese Portuguese (pt_PT) in the msgid string and translations to Bazilian Portuguese (pt_BR) in the msgstr for the strings that it is available. Other strings are empty.
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla and OpenOffice type files which contain translatable messages (.dtd, .properties or GSI files) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla or OpenOffice can understand (a XPI Language Pack or a GSI file). The Toolkit can be used for OpenOffice or for any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
The po2oo program converts a tree of PO files (that was either generated by oo2po or taken from the OpenOffice website, and then translated and filtered) into a GSI file that can be integrated into OpenOffice (a file that contains all the messages used by OpenOffice in a format that makes their integration easy).
As input, po2oo takes the folder (the tree) that contains all your PO files.
In order to make sure that the file generated is equivalent to the original one, the exact original (same version) English GSI file that was used to generate the POs by oo2po is used here as a template.
As output it produces a GSI file that can be automatically integrated in OpenOffice.
Inside the file, it is necessary to include the locale definition for which the messages are, this is done using the -l option.
By default, po2oo does not include in the final GSI file translations that are marked as fuzzy in the PO file, it includes the English original message instead. If it is considered better to include these translations, the --fuzzy option needs to be used.
If a reference language different than English was used for generating the PO files that we are working with (the --source-language option was used in oo2po), then it is necessary to again specify this language in po2oo, using the same --source-language option, with exactly the same locale code that was used in oo2po.
Conversion of translated PO files into an OpenOffice native GSI file
usage: po2oo [options] -i INPUT -o OUTPUT -t TEMPLATE -l LOCALE [--source-language==ISO]
Example:
oo2po -x CVS -x '*.diff' –i locale –t en_US.sdf -o en_CL.sdf -l en-CL
Given a directory called locale that contains all the OOo PO files that have been translated to your language, and given en_US.sdf, the original GSI file from which those PO files were originated,create a new GSI file with the translations called es_CL.sdf, using the locale code es-CL inside that file. Ignore files and directores called CVS or files that have the .diff extension.
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla and OpenOffice type files which contain translatable messages (.dtd, .properties or GSI files) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla or OpenOffice can understand (a XPI Language Pack or a GSI file). The Toolkit can be used for OpenOffice or for any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
The pot2po program has two possible funtions:
It takes as INPUT the name of the folder that contains the POT files, as OUTPUT the name of the folder to which the PO files will be created, and as a TEMPLATE the directory that contains the PO files for the old version of the same product.
Upgrade an applications PO files to the new version, maintaining the translations
usage: pot2po [options] -i INPUT -o OUTPUT -t TEMPLATE
Example:
pot2po –i new_version_pots –t old_version_pos -o new_version_pos
Given a set of already translated PO files for a product A, localed in the folder old_version_pos, and a set of POT files for a newer version of the same product A, in folder new_version_pots (both trees being identical), a new tree is created in new_version_pos that has copies of all the files in new_version_pots, but the new files have ".po" extensions. All translated messages that have been found in the same files in old_version_pos have been copied into these new files. As a result, new_version_pos contains the PO files for the new version, and only new messages that were not present in the old version need to be translated now.
Create PO files from a set of POT files
usage: pot2po [options] -i INPUT -o OUTPUT
Example:
pot2po –i pot_files -o po_files
Given set of POT files in folder po_files, create an equivalent set of PO files in folder po_files.
This program is part of the Translate Toolkit, a package designed to facilitate the translation of Open Source applications to new languages. Tools within the package are used to convert the Mozilla and OpenOffice type files which contain translatable messages (.dtd, .properties or GSI files) to PO format (a standard file format used in Open Source). PO files can be easily translated using specialized editors. Then these tools are once again used to pack the translated files into a format that Mozilla or OpenOffice can understand (a XPI Language Pack or a GSI file). The Toolkit can be used for OpenOffice or for any of the Mozilla family applications (Firefox, Thunderbird, Mozilla, etc.).
The pocount program counts the number of messages and words (translatable words words included in the messages) in a PO (or POT) file or in a folder or tree containing PO (or POT) files.
Count the number of messages and words.
usage: pocount [options] PATH
Example:
pocount afile.po
Returns the number of messages and translatable words in the afile.po file.
pocount po_folder
Returns the aggregated number of messages and translatable words in all PO and POT files contained in the directory po_folder.
Given a PO file, or a set of PO files, the pofilter program tests if the entries of the(se) file(s) fulfill certain conditions of correctness. The incorrect entries (each entry being composed of a msgid original string and a msgstr translated string) are saved into a new file, so that entries in this file can be corrected and then merged back into the PO file (by using the program pomerge).
For each entry considered as not correct by pofilter, it will include a standard PO entry in the output file, preceded by a comment explaining the type of error detected and by a comment identifying the translation as fuzzy. Such message may something like:
#_whitespace: whitespace at the beginning or end of the string did not match #, fuzzy #_test: test description
PO filter can be applied to a single file, to all the PO files in a directory or to all the PO files in a given tree. The output will take the same shape as the input, creating a file, a directory or a tree of files.
There are quite a number of filters that may be used in the program, each one of them testing for a given condition of correctness. The user may select which filters he wishes to use. These filters are:
· blank - Checks whether a translation is totally blank · doublequoting - Checks whether double quoting is consistent between the two strings · endpunc - Checks whether punctuation at the end of the strings match · escapes - Checks whether escaping is consistent between the two strings · numbers - Checks whether numbers of various forms are consistent between the two strings · purepunc - Checks that strings that are purely punctuation are not changed · short - Checks whether a translation is much shorter than the original string · simplecaps - Checks the capitalisation of two strings isn't wildly different · singlequoting - Checks whether single quoting is consistent between the two strings · startpunc - Checks whether punctuation at the beginning of the strings match · unchanged - Checks whether a translation is basically identical to the original string · untranslated - Checks whether a string has been translated at all · variables - Checks whether variables of various forms are consistent between the two strings · whitespace - Checks whether white spaces at the beginning and end of the strings match · musttranslatewords - Checks that words configured as definitely translatable don't appear in the translation. So if you want 'OK' to always be translated you can now flag when it appears as 'OK' in the translation. · notranslatewords - Checks that words configured as untranslatable appear in the translation too. For example, if you don't want brand names eg. Writer, Calc, Draw, Impress translated then you can check that they also appear untranslated in the translation. · spellcheck - Checks words that don't pass a spell check. Spell checks with Enchant, failing that, jToolkit the errors and suggestions appear in the error message. Word that also fail in the msgid are ignored ie if some word fails an English check then we ignore it in the translation this should prevent you having to see all brand names and program names as errors. · validchars - Checks that only characters specified as valid appear in the translation. You create a list of valid characters for your language. Anything that does not appear will be flagged. This help catch UTF-8 encoding issues. Be aware that you need to add some strange characters like percent, degree, etc. · autocorrect - Contrary to other functions of pofilter, this switch will not only extract string to an output file, it will actually send to the output files corrected strings. It will: a) Remove/add a white space at the beginning and end of a message so that the msgid and msgstr match. b) It will try to match the capitals at the beginning of a sentence. Ie if you translated in lowercase and the original is uppercase then it will change your first letter to uppercase. c) If you left out the ellipses (...) or a colon that are present in the original, then it will add them. If you have them and they shouldn't be there then it will delete them. This should be used only in scripts that have capital and follow western typographic rules (such as not placing a space before a punctuation mark or using Latin colon characters). It should not be used on CTL or East Asian languages. usage: pofilter [options] -i INPUT -o OUTPUT
This function takes translated messages from a PO file and used them to fill the translation field (msgstr) of another PO file that has at least some identical messages in English (which need to be translated the same way). It is useful for updating translations to new version of a product. The PO file for the new product usually has almost all the messages of the old version, but it also has new messages. This utility fill in the old translations in the new file, leaving only empty the fields for translations that did not exist before, and therefore helping translators avoid having to retype the translations.
It is also used – in conjunction with pofilter - to correct errors in PO files. Pofilter will select the entries that have possible errors and place them in a separate file. Once these errors are corrected, pomerge can be use to automatically integrate (replace) the corrected translations in the old document.
For each entry in each target PO file (in the TEMPLATE folder), the program looks if there is an entry with identical original English string (msgid) in the file of the INPUT directory that has the same name. If it finds it, the replacement entry from the INPUT directory file will be used in the file written to the OUTPUT directory. If no entry is found in the INPUT directory file, the entry from the TEMPLATE directory file will be used.
pomerge can be used in two different ways, depending on if you want to create a new directory in which the resulting PO files are stored (without touching either the original PO files or the corrections), or if you want to directly modify the original PO files: if the TEMPLATE and OUTPUT folders are different, then the files in the TEMPLATE directory will not be affected, and new files will written to the OUTPUT directory. If the TEMPLATE and OUTPUT folders are identical, then the files in that FOLDER will be modified and corrected with the corrections made in the INPUT folder.
usage: pomerge [options]-i INPUT -o OUTPUT -t TEMPLATE
Examples :
pomerge -i errors/ -o existing_files/ -t existing_files
After generating an error directory by using the pofilter utility on the existing_files directory; and then correcting the mistakes in the files of the errors directory, this function merges the corrections back into the files of the existing_files directory (overwrites them, as the template and output directories are identical).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||