Skip to content

Commit 2a2aa8e

Browse files
committed
Merge branch 'ar/i18n-no-gettext'
* ar/i18n-no-gettext: i18n: Do not force USE_GETTEXT_SCHEME=fallthrough on NO_GETTEXT i18n: Make NO_GETTEXT imply fallthrough scheme in shell l10n add a Makefile switch to avoid gettext translation in shell scripts git-sh-i18n: restructure the logic to compute gettext.sh scheme
2 parents 5ce2b97 + 60f4079 commit 2a2aa8e

File tree

2 files changed

+59
-54
lines changed

2 files changed

+59
-54
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ all::
4747
# A translated Git requires GNU libintl or another gettext implementation,
4848
# plus libintl-perl at runtime.
4949
#
50+
# Define USE_GETTEXT_SCHEME and set it to 'fallthrough', if you don't trust
51+
# the installed gettext translation of the shell scripts output.
52+
#
5053
# Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
5154
# trust the langinfo.h's nl_langinfo(CODESET) function to return the
5255
# current character set. GNU and Solaris have a nl_langinfo(CODESET),
@@ -1521,6 +1524,7 @@ ifdef GETTEXT_POISON
15211524
endif
15221525
ifdef NO_GETTEXT
15231526
BASIC_CFLAGS += -DNO_GETTEXT
1527+
USE_GETTEXT_SCHEME ?= fallthrough
15241528
endif
15251529
ifdef NO_STRCASESTR
15261530
COMPAT_CFLAGS += -DNO_STRCASESTR
@@ -1887,6 +1891,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
18871891
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
18881892
-e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
18891893
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1894+
-e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
18901895
-e $(BROKEN_PATH_FIX) \
18911896
$@.sh >$@+
18921897
endef
@@ -2264,7 +2269,7 @@ cscope:
22642269
### Detect prefix changes
22652270
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
22662271
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
2267-
$(localedir_SQ)
2272+
$(localedir_SQ):$(USE_GETTEXT_SCHEME)
22682273

22692274
GIT-CFLAGS: FORCE
22702275
@FLAGS='$(TRACK_CFLAGS)'; \

git-sh-i18n.sh

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,69 @@ else
1616
fi
1717
export TEXTDOMAINDIR
1818

19-
if test -z "$GIT_GETTEXT_POISON"
19+
# First decide what scheme to use...
20+
GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
21+
if test -n "@@USE_GETTEXT_SCHEME@@"
22+
then
23+
GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
24+
elif test -n "@@USE_FALLTHROUGH_GETTEXT_SCHEME@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
25+
then
26+
: no probing necessary
27+
elif test -n "$GIT_GETTEXT_POISON"
2028
then
21-
if test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && type gettext.sh >/dev/null 2>&1
22-
then
23-
# This is GNU libintl's gettext.sh, we don't need to do anything
24-
# else than setting up the environment and loading gettext.sh
25-
GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
26-
export GIT_INTERNAL_GETTEXT_SH_SCHEME
27-
28-
# Try to use libintl's gettext.sh, or fall back to English if we
29-
# can't.
30-
. gettext.sh
31-
32-
elif test -z "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" && test "$(gettext -h 2>&1)" = "-h"
33-
then
34-
# We don't have gettext.sh, but there's a gettext binary in our
35-
# path. This is probably Solaris or something like it which has a
36-
# gettext implementation that isn't GNU libintl.
37-
GIT_INTERNAL_GETTEXT_SH_SCHEME=solaris
38-
export GIT_INTERNAL_GETTEXT_SH_SCHEME
39-
40-
# Solaris has a gettext(1) but no eval_gettext(1)
41-
eval_gettext () {
42-
gettext "$1" | (
43-
export PATH $(git sh-i18n--envsubst --variables "$1");
44-
git sh-i18n--envsubst "$1"
45-
)
46-
}
47-
48-
else
49-
# Since gettext.sh isn't available we'll have to define our own
50-
# dummy pass-through functions.
51-
52-
# Tell our tests that we don't have the real gettext.sh
53-
GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
54-
export GIT_INTERNAL_GETTEXT_SH_SCHEME
55-
56-
gettext () {
57-
printf "%s" "$1"
58-
}
59-
60-
eval_gettext () {
61-
printf "%s" "$1" | (
62-
export PATH $(git sh-i18n--envsubst --variables "$1");
63-
git sh-i18n--envsubst "$1"
64-
)
65-
}
66-
fi
67-
else
68-
# Emit garbage under GETTEXT_POISON=YesPlease. Unlike the C tests
69-
# this relies on an environment variable
70-
7129
GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
72-
export GIT_INTERNAL_GETTEXT_SH_SCHEME
30+
elif type gettext.sh >/dev/null 2>&1
31+
then
32+
# GNU libintl's gettext.sh
33+
GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
34+
elif test "$(gettext -h 2>&1)" = "-h"
35+
then
36+
# gettext binary exists but no gettext.sh. likely to be a gettext
37+
# binary on a Solaris or something that is not GNU libintl and
38+
# lack eval_gettext.
39+
GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
40+
fi
41+
export GIT_INTERNAL_GETTEXT_SH_SCHEME
7342

43+
# ... and then follow that decision.
44+
case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
45+
gnu)
46+
# Use libintl's gettext.sh, or fall back to English if we can't.
47+
. gettext.sh
48+
;;
49+
gettext_without_eval_gettext)
50+
# Solaris has a gettext(1) but no eval_gettext(1)
51+
eval_gettext () {
52+
gettext "$1" | (
53+
export PATH $(git sh-i18n--envsubst --variables "$1");
54+
git sh-i18n--envsubst "$1"
55+
)
56+
}
57+
;;
58+
poison)
59+
# Emit garbage so that tests that incorrectly rely on translatable
60+
# strings will fail.
7461
gettext () {
7562
printf "%s" "# GETTEXT POISON #"
7663
}
7764

7865
eval_gettext () {
7966
printf "%s" "# GETTEXT POISON #"
8067
}
81-
fi
68+
;;
69+
*)
70+
gettext () {
71+
printf "%s" "$1"
72+
}
73+
74+
eval_gettext () {
75+
printf "%s" "$1" | (
76+
export PATH $(git sh-i18n--envsubst --variables "$1");
77+
git sh-i18n--envsubst "$1"
78+
)
79+
}
80+
;;
81+
esac
8282

8383
# Git-specific wrapper functions
8484
gettextln () {

0 commit comments

Comments
 (0)