start
Table of Contents

moz2po and po2moz

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

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 inc.po, inc.pot, it.po, it.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), styles: msgid_comment, merge, 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, *, inc.po, inc.pot, it.po, it.pot, properties.po, properties.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)
--fuzzy use translations marked fuzzy
--nofuzzy don’t use translations marked fuzzy (default)

Examples

Creating POT files

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

You already have an XPI on your language but want to create a set of PO files:

moz2po -t en-US.xpi zu-ZA.xpi zu-po

This will create a set of PO files in zu-po with the source language being English US from en-US.xpi and the target language being taken from af-ZA.xpi

Of course you can also use a different source language:

moz2po -t pt-PT.xpi af-ZA.xpi pt-af-po

In this scenario we create a set of PO files in pt-af-po with the source language as Portugeuse (pt-PT.xpi) and the target language as Afrikaans (af-ZA.xpi)

Note: I’ve checked that you can build a valid XPI and it works1). But of course I don’t use this method at all so if you want to try this please first do a dry run to see that it work correctly. We’d hate to see you translate the whole of Firefox and not be able to use your work.

Creating an XPI

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

1) For the techincally minded, moz2po relies on the message location infomration stored in the #: lines in the PO files. It doesn’t use the msgid to reconstruct the PO files. Thus in rebuilding we don’t need to know the English and thus this method works