git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext
Date: Sat, 05 Jun 2010 06:57:25 -0700 (PDT)	[thread overview]
Message-ID: <m3zkz9pols.fsf@localhost.localdomain> (raw)
In-Reply-To: <1275704035-6552-2-git-send-email-avarab@gmail.com>

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> All of the interface messages in Git core are currently hardcoded in
> English. Change that by optionally enabling translation of the core C,
> Shell and Perl programs via GNU gettext. If you set the appropriate
> LC_* variables Git will speak your language, provided that someone has
> submitted a translation.
[...]

> Implementation and usage notes:
[...]
>  * Perl:
> 
>    Perl code that wants to be localized should use the new Git::I18n
>    module. It imports a __ function into the caller's package by
>    default.
> 
>    Instead of using the high level Locale::TextDomain interface I've
>    opted to use the low-level (equivalent to the C interface)
>    Locale::Messages module, which Locale::TextDomain itself uses.
> 
>    Locale::TextDomain does a lot of redundant work we don't need, and
>    some of it would potentially introduce bugs. It tries to set the
>    $TEXTDOMAIN based on package of the caller, and has its own
>    hardcoded paths where it'll search for messages.

Actually both of those can be set using Locale::TextDomain->import()
call.  See e.g. this answer on StackOverflow:
  http://stackoverflow.com/questions/2965626/examples-of-localization-in-perl-using-gettext-and-localetextdomain-with-fallb/2967872#2967872

>    [...] In any case, this is an issue wholly internal
>    Git::I18N. Its guts can be changed later if that's deemed
>    necessary.

Right.
 
> --- a/INSTALL
> +++ b/INSTALL
> @@ -93,6 +93,14 @@ Issues of note:
>  	  history graphically, and in git-gui.  If you don't want gitk or
>  	  git-gui, you can use NO_TCLTK.
>  
> +	- The GNU "libintl" library is used by default for localizing
> +	  Git. It needs a gettext.h on the system for C code, gettext.sh
> +	  for shell scripts, and libintl-perl for Perl programs.
> +
> +	  Set NO_GETTEXT to disable localization support and make Git only
> +	  use English. Under autoconf the configure script will do this
> +	  automatically if it can't find libintl on the system.
> +

Shouldn't you also add here that you need also "libintl-perl" to have
those commands that are written in Perl localized?

> diff --git a/Makefile b/Makefile
> index d5d6565..3040000 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -28,6 +28,15 @@ all::
>  # Define NO_EXPAT if you do not have expat installed.  git-http-push is
>  # not built, and you cannot push using http:// and https:// transports.
>  #
> +# Define NO_GETTEXT if you don't want to build with Git with gettext
> +# support. Building it requires GNU libintl, and additionally
> +# libintl-perl at runtime.
> +#
> +# Define NEEDS_LIBINTL if you haven't set NO_GETTEXT and your system
> +# needs to be explicitly linked to -lintl. It's defined automatically
> +# on platforms where we don't expect glibc (Linux, Hurd,
> +# GNU/kFreeBSD), which includes libintl.
[...]

> diff --git a/config.mak.in b/config.mak.in
> index 0d4b64d..a15f3c1 100644
> --- a/config.mak.in
> +++ b/config.mak.in
> @@ -32,6 +32,7 @@ NO_CURL=@NO_CURL@
>  NO_EXPAT=@NO_EXPAT@
>  NO_LIBGEN_H=@NO_LIBGEN_H@
>  HAVE_PATHS_H=@HAVE_PATHS_H@
> +NO_GETTEXT=@NO_GETTEXT@

No

  +NEEDS_LIBINTL=@NEEDS_LIBINTL@

(see also below)?

> diff --git a/configure.ac b/configure.ac
> index 71038fc..7bebfd8 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -730,6 +730,12 @@ AC_CHECK_HEADER([paths.h],
>  [HAVE_PATHS_H=])
>  AC_SUBST(HAVE_PATHS_H)
>  #
> +# Define NO_GETTEXT if you don't have libintl.h
> +AC_CHECK_HEADER([libintl.h],
> +[NO_GETTEXT=],
> +[NO_GETTEXT=YesPlease])
> +AC_SUBST(NO_GETTEXT)
> +#

No check for NEEDS_LIBINTL?  No check that gettext is properly set up
with AM_GNU_GETTEXT (protected with m4_ifdef)?

  +# Define NEEDS_LIBINTL if you haven't set NO_GETTEXT and your system
  +# needs to be explicitly linked to -lintl. It's defined automatically
  +# on platforms where we don't expect glibc (Linux, Hurd,
  +# GNU/kFreeBSD), which includes libintl.
  +AC_CHECK_LIB([c], [gettext],
  +[NEEDS_LIBINTL=],
  +[NEEDS_LIBINTL=YesPlease])
  +AC_SUBST(NEEDS_LIBINTL)
  +test -n "$NEEDS_LIBINTL" && LIBS="$LIBS -lintl"

Or something like that (following examples for NEEDS_SOCKET and
NEEDS_RESOLV in configure.ac).

> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 454880a..ae63316 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -37,6 +37,7 @@ ORIGINAL_TERM=$TERM
>  # For repeatability, reset the environment to known value.
>  LANG=C
>  LC_ALL=C
> +LANGUAGE=C
>  PAGER=cat
>  TZ=UTC
>  TERM=dumb

This ensures that testsuite is run without translation.  It is
required because tests often include checking output of git commands
against expected output.

But perhaps, in later commit, we should mark those test that check
porcelain output format with NO_GETTEXT or LANG_C, and add --gettext
or --intl or --localized to run (parts of) testsuite with localized
strings, checking if localization didn't broke some scripted command
(somewhere command parses output of other git command).

What do you think?

-- 
Jakub Narebski
Poland
ShadeHawk on #git

  parent reply	other threads:[~2010-06-05 13:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-05  2:13 [PATCH/RFC v7 0/2] Add infrastructure for translating Git with gettext Ævar Arnfjörð Bjarmason
2010-06-05  2:13 ` [PATCH/RFC v7 1/2] " Ævar Arnfjörð Bjarmason
2010-06-05  2:57   ` Jonathan Nieder
2010-06-05  3:28     ` Ævar Arnfjörð Bjarmason
2010-06-05  3:36       ` Jonathan Nieder
2010-06-05 15:19         ` Ævar Arnfjörð Bjarmason
2010-06-05 19:27           ` Jonathan Nieder
2010-06-05 19:47             ` Ævar Arnfjörð Bjarmason
2010-06-12 17:26               ` Jonathan Nieder
2010-06-05  3:01   ` Jonathan Nieder
2010-06-05  3:30     ` Ævar Arnfjörð Bjarmason
2010-06-05  3:38       ` Jonathan Nieder
2010-06-05 14:10         ` Ævar Arnfjörð Bjarmason
2010-06-05 18:59           ` Jonathan Nieder
2010-06-05 19:33             ` Ævar Arnfjörð Bjarmason
2010-06-05 20:16               ` Inline functions (Re: [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext) Jonathan Nieder
2010-06-05 13:57   ` Jakub Narebski [this message]
2010-06-05 16:19     ` [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext Ævar Arnfjörð Bjarmason
2010-06-05  2:13 ` [PATCH/RFC v7 2/2] Add initial C, Shell and Perl gettext translations Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zkz9pols.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).