@matheusbsbs / matheus-bagliano / commits / 309552295a
Fork 0

i18n: do not poison translations unless GIT_GETTEXT_POISON envvar is set

Tweak the GETTEXT_POISON facility so it is activated at run time instead of compile time. If the GIT_GETTEXT_POISON environment variable is set, _(msg) will result in gibberish as before; but if the GIT_GETTEXT_POISON variable is not set, it will return the message for human-readable output. So the behavior of mistranslated and untranslated git can be compared without rebuilding git in between. For simplicity we always set the GIT_GETTEXT_POISON variable in tests. This does not affect builds without the GETTEXT_POISON compile-time option set, so non-i18n git will not be slowed down. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Feb 22, 2011 at 23:41 UTC 309552295af4b0f2ddd1af15d919441b1744523a
4 files changed +26 -3
Makefile
+4 -1
@@ -217,7 +217,9 @@ all::
217 # Define NO_REGEX if you have no or inferior regex support in your C library.
218 #
219 # Define GETTEXT_POISON if you are debugging the choice of strings marked
220 -# for translation. This will turn all strings that use gettext into gibberish.
220 +# for translation. In a GETTEXT_POISON build, you can turn all strings marked
221 +# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
222 +# (to any value) in your environment.
223 #
224 # Define JSMIN to point to JavaScript minifier that functions as
225 # a filter to have gitweb.js minified.
@@ -1374,6 +1376,7 @@ ifdef NO_SYMLINK_HEAD
1376 BASIC_CFLAGS += -DNO_SYMLINK_HEAD
1377 endif
1378 ifdef GETTEXT_POISON
1379 + LIB_OBJS += gettext.o
1380 BASIC_CFLAGS += -DGETTEXT_POISON
1381 endif
1382 ifdef NO_STRCASESTR
gettext.c new
+14
@@ -0,0 +1,14 @@
1 +/*
2 + * Copyright (c) 2010 Ævar Arnfjörð Bjarmason
3 + */
4 +
5 +#include "git-compat-util.h"
6 +#include "gettext.h"
7 +
8 +int use_gettext_poison(void)
9 +{
10 + static int poison_requested = -1;
11 + if (poison_requested == -1)
12 + poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
13 + return poison_requested;
14 +}
gettext.h
+1 -1
@@ -16,7 +16,7 @@
16 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
17
18 #ifdef GETTEXT_POISON
19 -#define use_gettext_poison() 1
19 +extern int use_gettext_poison(void);
20 #else
21 #define use_gettext_poison() 0
22 #endif
t/test-lib.sh
+7 -1
@@ -1080,7 +1080,13 @@ test -z "$NO_PERL" && test_set_prereq PERL
1080 test -z "$NO_PYTHON" && test_set_prereq PYTHON
1081
1082 # Can we rely on git's output in the C locale?
1083 -test -z "$GETTEXT_POISON" && test_set_prereq C_LOCALE_OUTPUT
1083 +if test -n "$GETTEXT_POISON"
1084 +then
1085 + GIT_GETTEXT_POISON=YesPlease
1086 + export GIT_GETTEXT_POISON
1087 +else
1088 + test_set_prereq C_LOCALE_OUTPUT
1089 +fi
1090
1091 # test whether the filesystem supports symbolic links
1092 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS