]> git.ipfire.org Git - thirdparty/git.git/blame - git-sh-i18n.sh
Merge branch 'jh/p4-human-unit-numbers'
[thirdparty/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
d162b25f 20if test -n "@@USE_GETTEXT_SCHEME@@"
ad17ea73
AR
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
42f16113
JH
26elif type gettext.sh >/dev/null 2>&1
27then
28 # GNU libintl's gettext.sh
29 GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
30elif test "$(gettext -h 2>&1)" = "-h"
31then
32 # gettext binary exists but no gettext.sh. likely to be a gettext
33 # binary on a Solaris or something that is not GNU libintl and
34 # lack eval_gettext.
35 GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext
36fi
37export GIT_INTERNAL_GETTEXT_SH_SCHEME
5e9637c6 38
42f16113
JH
39# ... and then follow that decision.
40case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
41gnu)
42 # Use libintl's gettext.sh, or fall back to English if we can't.
43 . gettext.sh
44 ;;
45gettext_without_eval_gettext)
46 # Solaris has a gettext(1) but no eval_gettext(1)
47 eval_gettext () {
48 gettext "$1" | (
49 export PATH $(git sh-i18n--envsubst --variables "$1");
50 git sh-i18n--envsubst "$1"
51 )
52 }
b8fc9e43 53
42f16113 54 ;;
42f16113
JH
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 }
b8fc9e43 66
42f16113
JH
67 ;;
68esac
e00cf070 69
5e9637c6
ÆAB
70# Git-specific wrapper functions
71gettextln () {
72 gettext "$1"
73 echo
74}
75
76eval_gettextln () {
77 eval_gettext "$1"
78 echo
79}