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 2.7 or 3.5+ installed on your machine. The easiest way is to just run

$ pip install -U compare-locales

Running it

compare-locales gathers the directories to compare from a TOML file, usually found in $APP/locales/l10n.toml. The details of the configuration file are described in the l10n-config docs. You pass the path to the toml 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.toml ./l10n/ de

To check mobile, replace the previous line with:

$ compare-locales mobile/android/locales/l10n.toml ./l10n/ zh-TW

To check mail, suite, calendar that lives on comm-central,  you can either rely on the check-out of mozilla within comm-central repository that the regular comm-central build instructions generate:

$ compare-locales ./comm-central/mail/locales/l10n.toml ./l10n/ zh-TW

If you don't want to use a copy of mozilla-central in comm-central, you can run them separately:

$ compare-locales -Dmozilla=$PWD/mozilla-central comm-central/mail/locales/l10n.toml ./l10n/ zh-TW

If you're working on multiple projects in parallel, you can also pass all the toml files to compare-locales at once. To get a single result across the projects, specify the --unified flag:

$ compare-locales --unified browser/locales/l10n.toml mobile/android/locales/l10n.toml ./l10n/ de

Cross-channel and compare-locales

If you're working against the gecko-strings cross-channel repository, the toml configuration files are in the _configs subdirectory, browser.toml, mobile_android.toml, mail.toml and calendar.toml, and suite.toml.

Options

To get a brief list of available options, use the --help flag:

$ compare-locales --help

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 and words, 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.