start

moz2po and po2moz

moz2po converts Mozilla files to PO files. It wraps converters that handle .properties, .dtd, .xhtml and some strange Mozilla files. The tool can extract from an XPI file and build your complete XPI file from your PO files or work with files from Mozilla CVS. Thus providing a complete roundtrip for Mozilla localisation using PO files and PO editors.

Caution: The conversion to and from XPI files is no longer actively supported, please work directly against Mozilla CVS files.

Usage

moz2po [options] <xpi|dir> <po>
po2moz [options] <po> <xpi|dir>

Options (moz2po):

--version show program's version number and exit
-h, --help show this help message and exit
--manpage output a manpage based on the help
--progress=PROGRESS show progress as: dots, none, bar, names, verbose
--errorlevel=ERRORLEVEL show errorlevel as: none, message, exception, traceback
-iINPUT, --input=INPUT read from INPUT in inc, it, *, dtd, properties formats
-xEXCLUDE, --exclude=EXCLUDE exclude names matching EXCLUDE from input paths
-oOUTPUT, --output=OUTPUT write to OUTPUT in it.po, it.pot, manifest, xhtml.po, xhtml.pot, ini.po, ini.pot, rdf, js, *, html.po, html.pot, inc.po, inc.pot, dtd.po, dtd.pot, properties.po, properties.pot formats
-tTEMPLATE, --template=TEMPLATE read from TEMPLATE in it, *, properties, dtd, inc formats
--psyco=MODE use psyco to speed up the operation, modes: none, full, profile
-P, --pot output PO Templates (.pot) rather than PO files (.po)
--duplicates=DUPLICATESTYLE what to do with duplicate strings (identical source text): merge (default), msgid_comment, keep, msgid_comment_all

Options (po2moz):

--version show program's version number and exit
-h, --help show this help message and exit
--manpage output a manpage based on the help
--progress=PROGRESS show progress as: dots, none, bar, names, verbose
--errorlevel=ERRORLEVEL show errorlevel as: none, message, exception, traceback
-iINPUT, --input=INPUT read from INPUT in dtd.po, dtd.pot, ini.po, ini.pot, inc.po, inc.pot, manifest, it.po, it.pot, *, html.po, html.pot, js, rdf, properties.po, properties.pot, xhtml.po, xhtml.pot formats
-xEXCLUDE, --exclude=EXCLUDE exclude names matching EXCLUDE from input paths
-oOUTPUT, --output=OUTPUT write to OUTPUT in dtd, *, inc, it, properties formats
-tTEMPLATE, --template=TEMPLATE read from TEMPLATE in dtd, *, inc, it, properties formats
--psyco=MODE use psyco to speed up the operation, modes: none, full, profile
-lLOCALE, --locale=LOCALE set output locale (required as this sets the directory names)
--clonexpi=CLONEXPI clone xpi structure from the given xpi file
--fuzzy use translations marked fuzzy
--nofuzzy don't use translations marked fuzzy (default)

Examples

Creating POT files

cd mozilla
make -f tools/l10n/l10n.mk create-en-US
cd ..
moz2po -P l10n/en-US pot

First extract the correct en-US source files from Mozilla CVS, found in the mozilla directory, placing them in l10n/en-US. Then create a set of POT (-P) files in pot.

moz2po -P en-US.xpi pot

Creating set of POT (-P) files from the American English XPI, en-US.xpi and placing them in pot for use a PO Templates.

If you want to create a set of POT files with another base language try:

moz2po -P fr-FR.xpi fr-pot

This will create a set of POT files in fr-pot that have French as your source language.

Creating PO files from existing non-PO translations

If you have existing translations (Mozilla related or other Babelzilla files) and you wish to convert them to PO for future translation then the following generic instructions will work:

moz2po -t en-US af-ZA af-ZA_pofiles

This will combine the untranslated template en-US files from en-US combine them with your existing translations in af-ZA and output PO files to af-ZA_pofiles.

The following is a more detailed recipe for Mozilla translation against CVS:

cd mozilla
make -f tools/l10n/l10n.mk create-en-US
cd ..
moz2po -t l10n/en-US l10n/xh po/xh

This is against Mozilla CVS. First create your en-US reference files. Then using moz2po take the template en-US files in l10n/en-US and merge them with translations in l10n/xh placing the PO files in po/xh. The text from en-US will appear in the msgid and the text from xh will appear in the msgstr. Run pocount to determine how much work you need to to to bring your translations up to fully translated.

moz2po -t l10n/fr l10n/xh po/xh

For those who are not English fluent you can do the same with another languages. In this case msgid will contain the French text from l10n/fr. This is useful for translating where the translators other languages is not English but French, Spanish or Portuguese. Please make sure that the source languages i.e. the msgid language is fully translated as against en-US.

Creating an XPI or CVS ready translations

po2moz -lzu-ZA -t en-US.xpi zu zu-ZA.xpi

Create a Zulu language (-lzu-ZA) XPI called zu-ZA.xpi from translations found in zu using en-US.xpi as a template. We use a template to ensure that our DTD and .properties files appear exactly as those in en-US

po2moz -t l10n/en-US po/xh l10n/xh

Create Mozilla files using the templates files in l10n/en-US (see above for how to create them) with PO translations in po/xh and ouput then to l10n/xh. The files now in l10n/xh are ready for submission to Mozilla and can be used to build a language pack or translated version of Mozilla.

Issues

You can perform the bulk of your work (99%) with moz2po.

Localisation of XHTML is not yet perfect, you might want to work with the files directly.

Bug 129 tracks the outstanding features which would allow complete localisation of Mozilla including; all help, start pages, rdf files, etc. It also tracks some bugs.

Accesskeys don't yet work in .properties files and in several cases where the Mozilla dtd files don't follow the normal conventions, for example in security/manager/chrome/pippki/pref-ssl.dtd.po. You might also want to check the files mentioned in this bug 329444 where mistakes in the DTD-definitions cause problems in the matching of accelerators with the text.

You might want to give special attention to the following files since it contains customisations that are not really translations.

Also, all width, height and size specifications need to be edited with feedback from testing the translated interfaces.

There are some constructed strings in the Mozilla code which we can't do much about. Take good care to read the localisation notes. For an example, see mail/chrome/messenger/downloadheaders.dtd.po. In that specific file, the localisation note from the DTD file is lost, so take good care of those.

The file extension of the original Mozilla file is required to tell the Toolkit how to do the conversion. Therefore, a file like foo.dtd must be named foo.dtd.po in order to po2moz to recognise it as a DTD file.