Creating a Language Pack

To create a language pack, or a localization repack, you first need to go through the initial setup process.

Pre-build steps

In the .mozconfig, you want to have

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-firefox-build
ac_add_options --disable-compile-environment
ac_add_options --with-l10n-base=../l10n-central # path relative to MOZ_OBJDIR
ac_add_options --enable-application=[browser or mail]

The given path should have your localization directory as child (i.e., a subdirectory ab-CD where ab-CD is your locale code).

You still need to specify which application you're localizing (e.g., for Firefox, that's browser, Thunderbird would be mail).

Configure step

You need to prepare the build directory, which is done with

./mach configure

You only need to run this if the version number of Firefox changes.

WINDOWS: Replace make with mozmake in the commands below!

Creating a langpack

We will now merge the localized files from x-testing locale with the en-US files from the original source. 

Every time you want to create a langpack, you need to be in the directory obj-firefox-build/browser/locales.  It is likely that you will continue to generate language packs as your progress just to test your work.  While in that directory, issue the following command:

$ make merge-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir
x-testing:
  browser
    chrome
      browser
        aboutCertError.dtd
            // add and localize this file
        ...
        // lots of notifications about missing entities
        ...
x-testing:
changed: 6
missingInFiles: 6124
missing: 5
0% of entries changed

If you now preview the contents of the mergdir, you'll see that it contains the files which in your localization were missing some entities. All other files will be taken from en-US directly. It's now time to create a langpack with

$ make langpack-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir

Each time you need to generate a new langpack, you need to run these two commands.  Remember that you need to be in the directory obj-firefox-build/browser/locales.

$ make merge-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir
$ make langpack-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir

Now go to the dist directory to find your langpack ready to use!

$ cd ../../dist/install

Open the XPI file contained in this directory with Firefox to see your work. You have to set your selected language still. You can either use the Locale Switcher extension, or set it in about:config. Set the general.useragent.locale to your language code, in this case, x-testing, and restart Firefox once more.

L10n binary repack

For apps currently in development, you need to get the right strings for the build you use. Best is to create an installer there. First, we get the en-US builds. There is a target to get those, too,

Another way to test it to repack the en-US binary.

From the obj-firefox-build/browser/locales directory, download the most recent en-US nightly that will be repacked to include your locale.

$ make wget-en-US EN_US_BINARY_URL=http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora

If you're building on Mac 64 bit, you'll need to change the command slightly:

$ make wget-en-US EN_US_BINARY_URL=http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora MOZ_PKG_PLATFORM=mac

At some point, you should see the following success message:

Downloaded http://ftp.mozilla.org/pub/mozilla.o....en-US.mac.dmg to /Users/your_id/Mozilla/vc/firefox/browser/locales/../../dist/firefox-3.6b5pre.en-US.mac.dmg

The en-US binary has been downloaded. Let's unpack it

$ make unpack

Again, for 64-bit Mac, append MOZ_PKG_PLATFORM=mac to this command.

At the end of the process, you should see the following success message.

...
done unpacking

Let's check which revision the binary was built from.

$ make ident
fx_revision 237dccbcb967
buildid 20091126033851

You can now go back to your source hg clone.

$ cd  ../../../mozilla-aurora

And update the source code to this revision.

$ hg update -r 237dccbcb967
3 files updated, 0 files merged, 0 files removed, 0 files unresolved

The source code has been updated to the revision the binary was built from. Let's go to the build directory again and continue the repacking.

$ cd ../obj-firefox-build/browser/locales

We will now merge the localized files from x-testing locale with the en-US files from the original source. Issue the following command:

$ make merge-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir
rm -f -rf mergedir
MACOSX_DEPLOYMENT_TARGET= compare-locales -m mergedir /Users/your_id/Mozilla/vc/mozilla-aurora/browser/locales/l10n.ini /Users/your_id/Mozilla/vc/l10n-central x-testing
x-testing:
  browser
    chrome
      browser
        aboutCertError.dtd
            // add and localize this file
        ...
        // lots of notifications about missing entities
        ...
x-testing:
changed: 6
missingInFiles: 6124
missing: 5
0% of entries changed

If you now preview the contents of the mergdir, you'll see that it contains the files which in your localization were missing some entities. All other files will be taken from en-US directly. It's now time to repackage the en-US binary with

$ make installers-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir 

Again, for 64-bit Mac, append MOZ_PKG_PLATFORM=mac to this command.

Each time you want to generate a new binary (often called a "repack"), you need to run these two commands.  Remember that you need to be in the directory firefox-build/browser/locales.

$ make merge-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir
$ make installers-x-testing LOCALE_MERGEDIR=$(PWD)/mergedir 

At the end of the process, you should see the following success message.

mv -f "../../dist/l10n-stage/firefox-3.6b5pre.x-testing.mac.dmg" "../../dist/firefox-3.6b5pre.x-testing.mac.dmg"
repackaging done

Now go to the dist directory to find your repackaged binary ready to be installed!

$ cd ../../dist/
$ ls -l
total 100216
drwxr-xr-x  5 your_id  your_status       170 27 lis 13:33 branding
-rw-r--r--@ 1 your_id  your_status  25248119 26 lis 14:34 firefox-3.6b5pre.en-US.mac.dmg
-rw-r--r--@ 1 your_id  your_status  26056973 27 lis 13:40 firefox-3.6b5pre.x-testing.mac.dmg
drwxr-xr-x  3 your_id  your_status       102 27 lis 13:38 install
drwxr-xr-x  3 your_id  your_status       102 27 lis 13:40 l10n-stage
drwxr-xr-x  3 your_id  your_status       102 27 lis 13:37 xpi-stage

You can install your locale's binary just as you would an official one. Happy testing!

Document Tags and Contributors

 Last updated by: zbraniecki,