Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 93 lines (85 sloc) 2.008 kb
e00cf07 @avar git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers
avar authored
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
4 #
5e9637c @avar i18n: add infrastructure for translating Git with gettext
avar authored
5 # This is Git's interface to gettext.sh. See po/README for usage
6 # instructions.
7
8 # Export the TEXTDOMAIN* data that we need for Git
9 TEXTDOMAIN=git
10 export TEXTDOMAIN
11 if test -z "$GIT_TEXTDOMAINDIR"
12 then
13 TEXTDOMAINDIR="@@LOCALEDIR@@"
14 else
15 TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
16 fi
17 export TEXTDOMAINDIR
e00cf07 @avar git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers
avar authored
18
42f1611 @gitster git-sh-i18n: restructure the logic to compute gettext.sh scheme
gitster authored
19 # First decide what scheme to use...
20 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
ad17ea7 @raalkml add a Makefile switch to avoid gettext translation in shell scripts
raalkml authored
21 if test -n "@@USE_GETTEXT_SCHEME@@"
22 then
23 GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
ac06116 @gitster i18n: fix auto detection of gettext scheme for shell scripts
gitster authored
24 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
42f1611 @gitster git-sh-i18n: restructure the logic to compute gettext.sh scheme
gitster authored
25 then
26 : no probing necessary
27 elif test -n "$GIT_GETTEXT_POISON"
64a4295 @avar git-sh-i18n.sh: add GIT_GETTEXT_POISON support
avar authored
28 then
5e9637c @avar i18n: add infrastructure for translating Git with gettext
avar authored
29 GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
42f1611 @gitster git-sh-i18n: restructure the logic to compute gettext.sh scheme
gitster authored
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
5e9637c @avar i18n: add infrastructure for translating Git with gettext
avar authored
42
42f1611 @gitster git-sh-i18n: restructure the logic to compute gettext.sh scheme
gitster authored
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.
64a4295 @avar git-sh-i18n.sh: add GIT_GETTEXT_POISON support
avar authored
61 gettext () {
62 printf "%s" "# GETTEXT POISON #"
63 }
64
65 eval_gettext () {
66 printf "%s" "# GETTEXT POISON #"
67 }
42f1611 @gitster git-sh-i18n: restructure the logic to compute gettext.sh scheme
gitster authored
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
e00cf07 @avar git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers
avar authored
82
5e9637c @avar i18n: add infrastructure for translating Git with gettext
avar authored
83 # Git-specific wrapper functions
84 gettextln () {
85 gettext "$1"
86 echo
87 }
88
89 eval_gettextln () {
90 eval_gettext "$1"
91 echo
92 }
Something went wrong with that request. Please try again.