start

# Mozilla L10n Scripts

## Introduction

This page describes the purpose and usage of scripts available in the Translate Toolkit specifically for making the translation of Mozilla products easier.

Mozilla's move from CVS to Mercurial made a lot of these scripts necessary. For more information about Mozilla l10n from CVS, see the moz-l10n-builder page.

All of these scripts are available on Subversion from here.

We are currently generating POT files for most major betas, RCs and releases of Firefox and Thunderbird. They are available here: http://l10n.mozilla.org/pootle/pot/

As a start you might want to just use these POT files and gradually learn more about the processes described below. Contact us for more help on using these.

## Requirements

- The Translate Toolkit (>=1.3)
- All scripts in the `tools/mozilla` directory (from the project sources) should be executable and in your `PATH`.

## build_ff3.1_langs.sh

### Description

This is a simple bash script that embodies most of the Mozilla l10n process and does the following:

1. Update Mozilla sources
2. Update language files from Mozilla's L10n Mercurial repository.
3. Replace old l10n en-US files with a fresh copy from the updated source tree.
4. Create new POT files from the en-US l10n files.
5. Create archives of the POT files.
6. For each language:
   1. Update existing PO files if the checked out from a CVS, Subversion or Mercurial repository.
   2. Migrate PO files to new POT files.
   3. Create Mozilla l10n files for the language based on the migrated PO files.
   4. Create archives of the PO files.
   5. Build langpack for the language.

This script is used on the l10n.mozilla.org server to create most (if not all) of the files available from http://l10n.mozilla.org/pootle/. It was originally written as a stable way to provide these files and as such making it as general as possible was not the biggest requirement. This is evident in the script's very narrow focus.

### Usage

This script takes no command-line parameters and is only configurable via the variables at the top and, failing that, custom hacking of the script.

The variables are used in the following ways:

`BUILD_DIR` | The base build directory from where building is done.
`MOZCENTRAL_DIR` | The directory containing a checkout of the Mozilla source tree (from http://hg.mozilla.org/mozilla-central/).
`HG_LANGS` | A space-separated list of language codes to build for.
`L10N_DIR` | The directory where Mozilla l10n files (from l10n-central) should be collected.
`PO_DIR` | The directory containing the externally-hosted or previously available source PO files (ex. PO files managed in another VCS repository). It contains a sub-directory for each language.
`POPACK_DIR` | The output directory for PO archives.
`PORECOVER_DIR` | The directory to put recovered PO files in. It contains a sub-directory for each language.
`POT_INCLUDES` | A space-separated list of files to be included in POT archives.
`POTPACK_DIR` | The output directory for POT archives.
`POUPDATED_DIR` | The directory to use for updated PO files. It contains a sub-directory for each language.
`LANGPACK_DIR` | The directory to put langpacks (XPIs) in.
`FF_VERSION` | The version of Firefox that is being built for. This is used in the file names of archives.

It is strongly recommended that you mirror the directory structure specified by the default values of the `*_DIR` variables. For example the default value for `L10N_DIR` is `${BUILD_DIR}/l10n`, then you should put your l10n-central check-outs in the `l10n` directory under your main build directory (`BUILD_DIR`).

Basically, you should have an ideally separate build directory containing the following sub-directories: `l10n`, `mozilla-central`, `po`, `popacks`, `potpacks`, `po-updated` and `xpi` (if used). This way the only variable that need to be changed is `BUILD_DIR`.

## build_tb3_langs.sh

This is the script that the `build_ff3.1_langs.sh` script above was actually adapted from. It is 90% similar with the obvious exception that it is aimed at building Thunderbird 3.0 packages in stead of Firefox 3.1. Also note that this script uses the comm-central repository in stead of mozilla-central.

## buildxpi.py

### Description

Creats a XPI language pack from Mozilla sources and translated l10n files. This script has only been tested with Firefox 3.1 beta sources.

It is basically the scripted version of the process described on Mozilla's "Creating a language pack" page.

This script is used by `build_ff3.1_langs.sh` to build language packs in its final step.

Note: This script uses the `.mozconfig` file in your home directory. Any existing `.mozconfig` is renamed to `.mozconfig.bak` during operation and copied back afterwards.

### Usage

    buildxpi.py -L /path/to/l10n -s /path/to/mozilla-central -o /path/to/xpi_output af

Options:

`/path/to/l10n` | The path to the parent directory of the “af” directory containing the Afrikaans translated l10n files.
`/path/to/mozilla-central` | The path to the Firefox sources check out from Mercurial. Note that `--mozproduct` is not specified, because the default is `browser`. For Thunderbird (>=3.0) it should be `/path/to/comm-central` and `--mozproduct mail` should be specified.
`/path/to/xpi_output` | The path to the output directory.
`af` | The language (Afrikaans in this case) to build a language pack for.

## get_moz_enUS.py

### Description

A simple script to collect the en-US l10n files from a Mozilla source tree (`'comm-central`' or `'mozilla-central`') by traversing the product's `l10n.ini` file.

### Usage

    get_moz_enUS.py [options]

Options:

`-h`, `--help` | Show this help message and exit.
`-s SRCDIR`, `--src=SRCDIR` | The directory containing the Mozilla l10n sources. (default: `mozilla`)
`-d DESTDIR`, `--dest=DESTDIR` | The destination directory to copy the en-US locale files to. (default: `l10n`)
`-pMOZPRODUCT`, `--mozproduct=MOZPRODUCT` | The Mozilla product name. (default: `browser`)
`--delete-dest` | Delete the destination directory (if it exists).
`-v, --verbose` | Be more noisy.

## moz-l10n-builder

This is the pre-Mercurial build script originally written by Dwayne Bailey. This is the script that all the others on this page replaces for post-CVS Mozilla l10n.

Note: This script is not applicable to the l10n process of any Mozilla products after the move to Mercurial.

For more information about this script see its dedicated wiki page.

## moz_l10n_builder.py

This script was intended to be a simple and direct port of the `moz-l10n-builder` script from above. It has pro's and cons in comparison to the original, but is very similar for the most part. So for more information about this script, see the original script's wiki page.