Imported Upstream version 2.25.3
[platform/upstream/git.git] / git-sh-i18n.sh
index 6a27f68..8eef60b 100644 (file)
@@ -1,9 +1,8 @@
-#!/bin/sh
+# This shell library is Git's interface to gettext.sh. See po/README
+# for usage instructions.
 #
 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
 #
-# This is Git's interface to gettext.sh. See po/README for usage
-# instructions.
 
 # Export the TEXTDOMAIN* data that we need for Git
 TEXTDOMAIN=git
@@ -18,15 +17,17 @@ export TEXTDOMAINDIR
 
 # First decide what scheme to use...
 GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough
-if test -n "@@USE_GETTEXT_SCHEME@@"
+if test -n "$GIT_TEST_GETTEXT_POISON" &&
+           git env--helper --type=bool --default=0 --exit-code \
+               GIT_TEST_GETTEXT_POISON
+then
+       GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
+elif test -n "@@USE_GETTEXT_SCHEME@@"
 then
        GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@"
 elif test -n "$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"
 then
        : no probing necessary
-elif test -n "$GIT_GETTEXT_POISON"
-then
-       GIT_INTERNAL_GETTEXT_SH_SCHEME=poison
 elif type gettext.sh >/dev/null 2>&1
 then
        # GNU libintl's gettext.sh
@@ -54,6 +55,13 @@ gettext_without_eval_gettext)
                        git sh-i18n--envsubst "$1"
                )
        }
+
+       eval_ngettext () {
+               ngettext "$1" "$2" "$3" | (
+                       export PATH $(git sh-i18n--envsubst --variables "$2");
+                       git sh-i18n--envsubst "$2"
+               )
+       }
        ;;
 poison)
        # Emit garbage so that tests that incorrectly rely on translatable
@@ -65,6 +73,10 @@ poison)
        eval_gettext () {
                printf "%s" "# GETTEXT POISON #"
        }
+
+       eval_ngettext () {
+               printf "%s" "# GETTEXT POISON #"
+       }
        ;;
 *)
        gettext () {
@@ -77,6 +89,13 @@ poison)
                        git sh-i18n--envsubst "$1"
                )
        }
+
+       eval_ngettext () {
+               (test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
+                       export PATH $(git sh-i18n--envsubst --variables "$2");
+                       git sh-i18n--envsubst "$2"
+               )
+       }
        ;;
 esac