[PATCH 0 of 7] Gettext infrastructure and Danish translation
Martin Geisler
mg at daimi.au.dk
Fri Aug 22 15:16:10 UTC 2008
Hello everybody!
This patch series fixes a bunch of translation problems and finally
adds code to lookup translations from the generated XX.mo files.
* Patch 1 removes some code that tried to make plural forms by
appending 's'.
* Patch 2 does almost the same, but for templatefilters. You might
want to *skip* this patch since it looks strange that part of the
web interface is translated when the rest is not.
* Patch 3 marks some extra strings for translation.
* Patch 4 is sort of unrelated to the translation business -- but the
context for next patch overlaps with it, so I left it in.
* Patch 5 makes it easier to find the XX.mo files. The gettext module
would lookup XX.mo in
/usr/share/locale/XX/LC_MESSAGES/hg.mo
or something like that. But that makes it annoying to test new
translations and difficult for people who does not install to that
location. So I changed i18n.py to do the lookup itself, based on
code from gettext.py from Python, which should be okay since Python
code is under a GPL-compatible license. So for language XX
locale/XX.mo and ../locale/XX.mo are searched for relative to the
location of i18n.py. This is the same way templater.py uses to find
the templates directory.
* Patch 6 adds new targets to the Makefile for updating the hg.pot (PO
template) file and to generate XX.mo files. I don't particularly
like the update-mo target name I chose -- maybe someone can come up
with something better.
* Patch 7 has the first part of a Danish translation containing 200
translations (out of almost 1300). I am definitely not the right
person to do the entire Danish translation: I prefer English output
and only did this to test the infrastructure...
Problems:
* Many short strings make little sense in isolation, but this is
difficult to fix.
* Some strings use abbreviations ('repo', 'rev') which can be
difficult to carry over.
* Some strings build larger strings from smaller pieces, such as this
one from mercurial/commands.py:2208:
ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
% (m.rel(f), reason))
* Much of the help is in docstrings -- and pygettext.py can extract
those. But we don't want to translate all docstrings...
Also, the record extension runs *part* of a docstring through _()
which is clever, but not such a good idea from a translation point
of view.
* If this goes in, all tests should be run in the C locale to ensure
deterministic output.
* The dist target in the Makefile should probably depend on the
update-pot target.
* It needs testing :-) I don't know if the py2exe stuff works...
But please give it a try and let me know what you think! You can
create a new language by going to the po directory and running
msginit -l xx
where xx is your language code (not country code: da vs dk). Then edit
away and run
make update-mo
from the root to compile the .po file into a .mo file. Then set
LANG=xx and run hg.
More information about the Mercurial-devel
mailing list