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 19iftest -z"$GIT_GETTEXT_POISON" 20then 21iftest -z"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"&&typegettext.sh >/dev/null 2>&1 22then 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 26export 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 32eliftest -z"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS"&&test"$(gettext -h 2>&1)"="-h" 33then 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 38export GIT_INTERNAL_GETTEXT_SH_SCHEME 39 40# Solaris has a gettext(1) but no eval_gettext(1) 41 eval_gettext () { 42gettext"$1"| ( 43export PATH $(git sh-i18n--envsubst --variables "$1"); 44 git sh-i18n--envsubst"$1" 45) 46} 47 48else 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 54export GIT_INTERNAL_GETTEXT_SH_SCHEME 55 56gettext() { 57printf"%s""$1" 58} 59 60 eval_gettext () { 61printf"%s""$1"| ( 62export PATH $(git sh-i18n--envsubst --variables "$1"); 63 git sh-i18n--envsubst"$1" 64) 65} 66fi 67else 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 72export GIT_INTERNAL_GETTEXT_SH_SCHEME 73 74gettext() { 75printf"%s""# GETTEXT POISON #" 76} 77 78 eval_gettext () { 79printf"%s""# GETTEXT POISON #" 80} 81fi 82 83# Git-specific wrapper functions 84gettextln () { 85gettext"$1" 86echo 87} 88 89eval_gettextln () { 90 eval_gettext "$1" 91echo 92}