Compare-locales

compare-locales is a python script that helps localizers to check their work without running Firefox or another application.

If you want to run compare-locales on Windows, be sure to first install MozillaBuild.

Installation

compare-locales needs to be installed, and it requires that you have Python installed on your machine. The easiest way is to just run

$ sudo easy_install -U compare-locales

or, if you're on Windows:

$ easy_install -U compare-locales
# before you can do this you need to add python "Scripts" directory into windows "PATH" environment variable

if you have that set up, as I uploaded a current version to pypi. If you haven't, you want to read about that on EasyInstall, the sources are on http://hg.mozilla.org/l10n/compare-locales/.

Note that recent versions require a recent version of python including json, or the simplejson module to work. You can install it by running easy_install, or install python-simplejson package if you are running a Debian-based system (recommended).

Running it

This describes the calling syntax for versions 0.5 and beyond, for older versions, please check the older docs.

compare-locales gathers the directories to compare from an ini file, usually found in $APP/locales/l10n.ini. You pass both the path to the ini file and the parent dir of the localizations as first arguments, followed by the locale codes of the locales you want to compare. If you want to test the localization for de, run

$ compare-locales browser/locales/l10n.ini ../l10n/ de

As of version 0.5, the l10n directories don't need to be in a bound place relative to your mozilla dir. This works on the CVS branches as well as on mozilla-central.

If you are maintaining a single localization, you might need to move around your directory or creating a symbolic link to make compare-locales work. For example, to check current localizations on http://hg.mozilla.org/l10n-central/zh-TW/ against mozilla-central, you need to do the following:

$ cd ~/mozilla-repo
$ hg clone http://hg.mozilla.org/mozilla-central/ ./mozilla-central
$ hg clone https://hg.mozilla.org/l10n-central/zh-TW/ ./central-l10n # my working directory
$ compare-locales ./mozilla-central/browser/locales/l10n.ini ./central-l10n/ zh-TW # THIS WON'T WORK
$ mkdir ./l10n
$ ln -s ../central-l10n ./l10n/zh-TW
$ compare-locales ./mozilla-central/browser/locales/l10n.ini ./l10n/ zh-TW # THIS WILL WORK

To check mobile, replace the previous line with:

$ compare-locales ./mozilla-central/mobile/locales/l10n.ini ./l10n/ zh-TW

To check mail, suite, calendar that lives on comm-central, or other comm-<version>, you need to create a symbolic link named mozilla within comm-central repository that links to mozilla-central repository so compare-locales could access files in toolkit correctly:

(if you did everything above)
$ hg clone http://hg.mozilla.org/comm-central/ ./comm-central
$ compare-locales ./comm-central/mail/locales/l10n.ini ./l10n/ zh-TW # THIS WON'T WORK (for now)
$ ln -s ../mozilla-central ./comm-central/mozilla
$ compare-locales ./comm-central/mail/locales/l10n.ini ./l10n/ zh-TW # NOW IT WORKS

If you don't want to use symbolic links you can have folder structure similar to this:

/mozilla-repo/
       /comm-central/ # contains http://hg.mozilla.org/comm-central/
            /mozilla/ # sub-hg, contains http://hg.mozilla.org/mozilla-central/
       /zh-TW/ # contains http://hg.mozilla.org/l10n-central/zh-TW/
This will remove need for symbolic links.
$ compare-locales ./mozilla-repo/comm-central/mail/locales/l10n.ini ./mozilla-repo/ zh-TW
# this will work if run outside of /mozilla-repo directory

Options

Running

$ compare-locales --help

will give you a brief list of available options. Full description TBD.

The output

The output of compare-locales shows the missing and obsolete strings in a pseudo-diff format.

ab-CD
  browser
    chrome/browser
      browser.dtd
          +backForwardMenu.tooltip
          +fullZoomEnlargeCmd.commandkey3
          +fullZoomReduceCmd.commandkey2
          +fullZoomResetCmd.commandkey2
          +organizeBookmarks.label
          -showAllBookmarksCmd2.label
      migration/migration.dtd
          -importFromFile.accesskey
          -importFromFile.label
          +importFromHTMLFile.accesskey
          +importFromHTMLFile.label

You can assume changed strings when you see entities removed and added with a similar name. The file names will be shown in a hierarchical form, so in the example above, your files are browser.dtd in ab-CD/browser/chrome/browser and migration.dtd in another directory level deeper.

The output closes with a summary, giving the total counts of missing and obsolete strings (individual entries in missing files are not counted yet), and some statistics on how many strings are changed or not, excluding access- and commandkeys. That gives localizers an idea on how thorough the localization is. This number won't reach 100% in general, mid 80s should be the target, though.

Pass --json to get just the summary in JSON format.

Document Tags and Contributors

 Contributors to this page: teoli, Aryx, Sheppy, AxelHecht, Mikeyy, jswisher, timdream, Tonymec, stasm, BenoitL, Ehsan
 Last updated by: Aryx,