Thread (19 messages) flat view 19 messages, 3 authors, 2016-06-15

Re: [PATCH/RFC v7 1/2] Add infrastructure for translating Git with gettext

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:48:55

Ævar Arnfjörð Bjarmason  [off-list ref] 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.
 
quoted hunk ↗ jump to hunk
--- 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?
quoted hunk ↗ jump to hunk
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.
[...]
quoted hunk ↗ jump to hunk
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)?
quoted hunk ↗ jump to hunk
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).
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help