i18n: rebase-interactive: mark strings for translation
[git/git.git] / git-sh-i18n.sh
CommitLineData
11d62145
JN
1# This shell library is Git's interface to gettext.sh. See po/README
2# for usage instructions.
e00cf070
ÆAB
3#
4# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
5#
5e9637c6
ÆAB
6
7# Export the TEXTDOMAIN* data that we need for Git
8TEXTDOMAIN=git
9export TEXTDOMAIN
10if test -z "$GIT_TEXTDOMAINDIR"
11then
12 TEXTDOMAINDIR="@@LOCALEDIR@@"
13else
14 TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
15fi
16export TEXTDOMAINDIR
e00cf070 17
42f16113
JH
18# First decide what scheme to use...
19GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
ad17ea73
AR
20if test -n "@@USE_GETTEXT_SCHEME@@"
21then
22 GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
ac06116d 23elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
42f16113
JH
24then
25 : no probing necessary
26elif test -n "$GIT_GETTEXT_POISON"
64a42951 27then
5e9637c6 28 GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
42f16113
JH
29elif type gettext.sh >/dev/null 2>&1
30then
31 # GNU libintl's gettext.sh
32 GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
33elif test "$(gettext -h 2>&1)" = "-h"
34then
35 # gettext binary exists but no gettext.sh. likely to be a gettext
36 # binary on a Solaris or something that is not GNU libintl and
37 # lack eval_gettext.
38 GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
39fi
40export GIT_INTERNAL_GETTEXT_SH_SCHEME
5e9637c6 41
42f16113
JH
42# ... and then follow that decision.
43case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
44gnu)
45 # Use libintl's gettext.sh, or fall back to English if we can't.
46 . gettext.sh
47 ;;
48gettext_without_eval_gettext)
49 # Solaris has a gettext(1) but no eval_gettext(1)
50 eval_gettext () {
51 gettext "$1" | (
52 export PATH $(git sh-i18n--envsubst --variables "$1");
53 git sh-i18n--envsubst "$1"
54 )
55 }
56 ;;
57poison)
58 # Emit garbage so that tests that incorrectly rely on translatable
59 # strings will fail.
64a42951
ÆAB
60 gettext () {
61 printf "%s" "# GETTEXT POISON #"
62 }
63
64 eval_gettext () {
65 printf "%s" "# GETTEXT POISON #"
66 }
42f16113
JH
67 ;;
68*)
69 gettext () {
70 printf "%s" "$1"
71 }
72
73 eval_gettext () {
74 printf "%s" "$1" | (
75 export PATH $(git sh-i18n--envsubst --variables "$1");
76 git sh-i18n--envsubst "$1"
77 )
78 }
79 ;;
80esac
e00cf070 81
5e9637c6
ÆAB
82# Git-specific wrapper functions
83gettextln () {
84 gettext "$1"
85 echo
86}
87
88eval_gettextln () {
89 eval_gettext "$1"
90 echo
91}