cat-file tests: test for missing/bogus object with -t, -s and -p
[git/debian.git] / git-sh-i18n.sh
blobe3d9f4836db14e5834372a8bb61ee3c27c82f34f
1 # This shell library is Git's interface to gettext.sh. See po/README
2 # for usage instructions.
4 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
7 # Export the TEXTDOMAIN* data that we need for Git
8 TEXTDOMAIN=git
9 export TEXTDOMAIN
10 if test -z "$GIT_TEXTDOMAINDIR"
11 then
12 TEXTDOMAINDIR="@@LOCALEDIR@@"
13 else
14 TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR"
16 export TEXTDOMAINDIR
18 # First decide what scheme to use...
19 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
20 if test -n "@@USE_GETTEXT_SCHEME@@"
21 then
22 GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
23 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
24 then
25 : no probing necessary
26 elif type gettext.sh >/dev/null 2>&1
27 then
28 # GNU libintl's gettext.sh
29 GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu
30 elif test "$(gettext -h 2>&1)" = "-h"
31 then
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
37 export GIT_INTERNAL_GETTEXT_SH_SCHEME
39 # ... and then follow that decision.
40 case "$GIT_INTERNAL_GETTEXT_SH_SCHEME" in
41 gnu)
42 # Use libintl's gettext.sh, or fall back to English if we can't.
43 . gettext.sh
45 gettext_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"
54 eval_ngettext () {
55 ngettext "$1" "$2" "$3" | (
56 export PATH $(git sh-i18n--envsubst --variables "$2");
57 git sh-i18n--envsubst "$2"
62 gettext () {
63 printf "%s" "$1"
66 eval_gettext () {
67 printf "%s" "$1" | (
68 export PATH $(git sh-i18n--envsubst --variables "$1");
69 git sh-i18n--envsubst "$1"
73 eval_ngettext () {
74 (test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
75 export PATH $(git sh-i18n--envsubst --variables "$2");
76 git sh-i18n--envsubst "$2"
80 esac
82 # Git-specific wrapper functions
83 gettextln () {
84 gettext "$1"
85 echo
88 eval_gettextln () {
89 eval_gettext "$1"
90 echo