compare-locales

July 10th, 2008 by seth bindernagel

You may have noticed in the past few months that I have been writing more and more about Mozilla l10n and our tools development process.

In addition, over the last two weeks, I’ve set up a handful of meetings with localizers from several Indic languages who have been poking us to find out what they need to do to start buidling, testing, and eventually shipping a localized version of Firefox 3.  Mic has also been reaching out to localizer groups to set up team-to-team meetings and overall, I think it has been successful.

One thing I saw repeatedly in those meetings that seemed particularly helpful was Pike using his compare-locales tool that he developed that shows the progress of a localization compared to the current en-US source code.

So, last Friday, I decided to learn how to use this tool so I might be able to help Pike steer localizers to where work needs to be done….and along the way, comment on the pain points.  Here is what I did and learned:

I went to MDC and looked up how to run compare-locales.  Pike wrote this documentation and it was really helpful.

After reading through this, my first task was to figure out if I had Python installed.  In fact, I did.  Version 2.5.1.  I checked in with Pike and he told me that he had tested compare-locales with versions of Python 2.3, so I knew I was ok.  To run this, you’ll need 2.3 or higher.

With Python installed, I had to check to see if I had easy_install on my machine.  And, I lucked out again!  I had it installed on my machine.  Pike gives some good documentation on how to get easy_install if you don’t have it.

I then ran the following command from the shell:

# Install “compare-locales”.  ”easy_install compare-locales”

But, this failed.  I hit my first pain point.  For some reason, I was not able to install to the directory /usr/local/bin.  I asked for a bit of help from one of these developer guys and ran the following:

$ mkdir /Users/bindernagel/bin
$ export PYTHONPATH=/Users/bindernagel/bin
$ easy_install –install-dir=/Users/bindernagel/bin compare-locales

Success.  Thanks, Seth Spitzer.

I then had to get the en-US source code for the browser.  This was kind of a big deal for me here…checking out the Mozilla source for Firefox for the first time…well, I thought it was cool…now I can build my own version of Firefox one day.

(I’ll attach the MDC doc I used to do this and the commands I ran in the comment section of this blog post.)

Once I had the browser source from CVS locally, I had to get all the localizations for Firefox.  This was another pain point.  I didn’t really know how to find ALL localizations, which I what I needed if I wanted to be helpful to localizers. This was the last pain point.  But, I got a bit more help and we found this:

$ make -f client.mk l10n-checkout MOZ_CO_PROJECT=browser MOZ_CO_LOCALES=all

If I were to make an addition to the MDC doc about compare-locales, I might put this line, or a locale-specific command in the instructions.

Once I had this, I was able to run my first compare-locale.  I chose German (de) and here was the output in my terminal prompt:

keys: 900
unchanged: 659
changed: 4427
87% of entries changed

This is a summary of the localization of the team from Germany.

  • Keys are access keys typically (DTD files) that need some localization.
  • Unchanged are strings that are in en-US that do not need to be changed.
  • Changed gives the number of strings localized by the team

When I ran this compare-locale, de was complete.  If de needed more localization work, a list of files would have been given.

Ping me if you want to learn how to do this.  If you already do, please list the pain points you experienced when trying to do this yourself.  I’ll gather those and amend the MDC document accordingly (with approval from Pike).

Tags: , , | Categories: Uncategorized

  1. I ran these commands to get the source, which I got from MDC here:

    [http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS#Checking_Out_a_New_Source_Tree]

    $ mkdir source
    $ cd source
    $ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co
    mozilla/client.mk
    $ cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co
    mozilla/browser/config/mozconfig
    $ make -f client.mk checkout MOZ_CO_PROJECT=browser

  2. missed step 5 above:

    $ cd mozilla

  3. Håvard Mork

    Version 0.4.23 does not seem to work on my Python 2.4, but version 0.4.1 from http://pypi.python.org/simple/compare-locales/ works.

    The error I got was:
    Traceback (most recent call last):
    [...]
    File “build/bdist.macosx-10.3-fat/egg/Mozilla/CompareLocales.py”, line 413, in compareApp
    File “build/bdist.macosx-10.3-fat/egg/Mozilla/CompareLocales.py”, line 198, in compareWith
    File “build/bdist.macosx-10.3-fat/egg/Mozilla/CompareLocales.py”, line 376, in compare
    File “build/bdist.macosx-10.3-fat/egg/Mozilla/CompareLocales.py”, line 312, in notify
    NameError: global name ‘all’ is not defined

    Is compare-locales just for Firefox l10n, or can it be used with mail as well?

  4. Hi Håvard:

    I went through some old dev-l10n emails and found this question and answer:

    “I ran compare-locale to test my Thunderbird localization. But it gives “tested’: ['browser','toolkit']” as the last line no “mail” there. I replaced the browser with mail in the “.mozconfig ” file. I googled and check for dev-l10n-web Archives for info but no luck. Can someone give me a point, please?”

    This answer was posted:

    “Run it with ‘-a mail’”

    That seemed to solve the problem posed in the question. Not sure if that helps, hope it does.

    -Seth

  5. That’s exactly what I needed to put all the pieces of information about compare-locales together. Thanks!

  6. Håvard Mork

    Works great! Thanks!

  7. Hi.

    It works perfectly for the Mozilla Mexico project. I can make our first language pack (zap-MX-diiste) a Zapotec dialect, and I didn’t know the exactly numbers of files translated, thanks!

  8. Håvard, you may want to try to

    easy_install -U compare-locales

    or

    easy_install -m compare-locales

    It seems that your local install doesn’t pick up the current version.

  9. Ognyan Kulev

    Axel,

    I had the same problem as Håvard (but for browser) and installing 0.4.1 instead of 0.4.23 fixed it.

  10. Hrm. Found it. all(), new in python 2.5.

    I’ll fix that in an upcoming release.