[PATCH/RFC 0/5] Add internationalization support to Git
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- May 29, 2010, 22:45 UTC
- Message-ID
- <1275173125-21010-1-git-send-email-avarab@gmail.com>
Here's an updated version of the patch series begun by Jeff Epler to make Git optionally translatable with GNU gettext. I'm submitting it now because I'd like to get some comments on the approach, and specifically whether something like this is likely to be accepted into Git.
Changes since the initial submission:
* Merged in changes to wt-status.c from the master branch
* Made Gettext play nice with the build system (.gitignore & make
clean) * Added support for making Git's shell scripts translatable by
importing the gettext functions in git-sh-setup.sh, or supplying
replacements if they don't work. Comments from shellscript-savy
list members about whether the fallbacks work on odd non-GNU
shells are especially welcome. I made three strings in git-pull.sh translatable as a proof of
concept. One problem that I ran into is that xgettext(1) seems
very particular when picking up translation strings. It accepts
this:gettext "hello world"; echo
but not this:
die gettext "hello world"; die
or this:
gettext <<"END"; hello world END
Maybe there's a way to make it play nice. But I just used a large
multiline string as a workaround. I don't know what to do about
'die gettext' other than define a 'die_gettext' wrapper function
and use `xgettext --keyword=die_gettext'. * There's now a skeleton is.po file. It just has one string
translated. I can't figure out what to call any of the Git core
concepts so I'm stuck :)Next up:
* Perl support. I haven't yet found what the best way of using
libintl from Perl would be. GNU recommends Locale::TextDomain, but
Debian only seems to have Locale::gettext which is a more
lightweight wrapper. In any case I can write a wrapper for those/the shell command and
fall back on the hardcoded strings like the C/Shell code does.Most importantly. If there are any interested list members that want to translate Git, it's now ready for translators. You just have to add a po/$lang.po file with your favorite editor and Git's build system will install it.
One thing I haven't done is to try to go ahead and make massive changes to the Git source code to make everything translatable. Due to their nature it's a big headache to maintain changes like that if anything moves upstream.
Of course that's subject to change if other people are interested in contributing.
For reference, here's the branch on GitHub I'm hacking this in, patches welcome:
http://github.com/avar/git/compare/master...topic/git-gettext
Jeff Epler (1): Add infrastructure for translating Git with gettext
Ævar Arnfjörð Bjarmason (4): gitignore: Ignore files generated by gettext Makefile: Remove Gettext files on make clean gettext: Add a skeleton po/is.po Add infrastructure to make shellscripts translatable
.gitignore | 1 + Makefile | 35 +++++++- gettext.c | 17 ++++ gettext.h | 15 +++ git-pull.sh | 15 ++-- git-sh-setup.sh | 33 +++++++ git.c | 3 + po/.gitignore | 1 + po/is.po | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ wt-status.c | 129 +++++++++++++------------ 10 files changed, 465 insertions(+), 72 deletions(-) create mode 100644 gettext.c create mode 100644 gettext.h create mode 100644 po/.gitignore create mode 100644 po/is.po