Update draft release notes to 1.7.9
[git] / git-sh-i18n.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
4 #
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
18
19 if test -z "$GIT_GETTEXT_POISON"
20 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
71         GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
72         export GIT_INTERNAL_GETTEXT_SH_SCHEME
73
74         gettext () {
75                 printf "%s" "# GETTEXT POISON #"
76         }
77
78         eval_gettext () {
79                 printf "%s" "# GETTEXT POISON #"
80         }
81 fi
82
83 # Git-specific wrapper functions
84 gettextln () {
85         gettext "$1"
86         echo
87 }
88
89 eval_gettextln () {
90         eval_gettext "$1"
91         echo
92 }