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 9TEXTDOMAIN=git 10export TEXTDOMAIN 11iftest -z"$GIT_TEXTDOMAINDIR" 12then 13 TEXTDOMAINDIR="@@LOCALEDIR@@" 14else 15 TEXTDOMAINDIR="$GIT_TEXTDOMAINDIR" 16fi 17export TEXTDOMAINDIR 18 19# First decide what scheme to use... 20GIT_INTERNAL_GETTEXT_SH_SCHEME=fallthrough 21iftest -n"@@USE_GETTEXT_SCHEME@@" 22then 23 GIT_INTERNAL_GETTEXT_SH_SCHEME="@@USE_GETTEXT_SCHEME@@" 24eliftest -n"@@USE_FALLTHROUGH_GETTEXT_SCHEME@@$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS" 25then 26: no probing necessary 27eliftest -n"$GIT_GETTEXT_POISON" 28then 29 GIT_INTERNAL_GETTEXT_SH_SCHEME=poison 30eliftypegettext.sh >/dev/null 2>&1 31then 32# GNU libintl's gettext.sh 33 GIT_INTERNAL_GETTEXT_SH_SCHEME=gnu 34eliftest"$(gettext -h 2>&1)"="-h" 35then 36# gettext binary exists but no gettext.sh. likely to be a gettext 37# binary on a Solaris or something that is not GNU libintl and 38# lack eval_gettext. 39 GIT_INTERNAL_GETTEXT_SH_SCHEME=gettext_without_eval_gettext 40fi 41export GIT_INTERNAL_GETTEXT_SH_SCHEME 42 43# ... and then follow that decision. 44case"$GIT_INTERNAL_GETTEXT_SH_SCHEME"in 45gnu) 46# Use libintl's gettext.sh, or fall back to English if we can't. 47 . gettext.sh 48;; 49gettext_without_eval_gettext) 50# Solaris has a gettext(1) but no eval_gettext(1) 51 eval_gettext () { 52gettext"$1"| ( 53export PATH $(git sh-i18n--envsubst --variables "$1"); 54 git sh-i18n--envsubst"$1" 55) 56} 57;; 58poison) 59# Emit garbage so that tests that incorrectly rely on translatable 60# strings will fail. 61gettext() { 62printf"%s""# GETTEXT POISON #" 63} 64 65 eval_gettext () { 66printf"%s""# GETTEXT POISON #" 67} 68;; 69*) 70gettext() { 71printf"%s""$1" 72} 73 74 eval_gettext () { 75printf"%s""$1"| ( 76export PATH $(git sh-i18n--envsubst --variables "$1"); 77 git sh-i18n--envsubst"$1" 78) 79} 80;; 81esac 82 83# Git-specific wrapper functions 84gettextln () { 85gettext"$1" 86echo 87} 88 89eval_gettextln () { 90 eval_gettext "$1" 91echo 92}