git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 3/4] git-sh-i18n.sh: add GIT_GETTEXT_POISON support
Date: Sat, 14 May 2011 13:47:44 +0000	[thread overview]
Message-ID: <1305380865-21339-4-git-send-email-avarab@gmail.com> (raw)
In-Reply-To: <1305380865-21339-1-git-send-email-avarab@gmail.com>

Change git-sh-i18n.sh to support the GIT_GETTEXT_POISON environment
variable like gettext.c does, this ensures that tests that use
git-sh-i18n.sh will fail under GETTEXT_POISON=YesPlease if they rely
on Git's C locale messages without declaring that they do.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 git-sh-i18n.sh |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index ea05e16..32ca59d 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -5,13 +5,25 @@
 # This is a skeleton no-op implementation of gettext for Git. It'll be
 # replaced by something that uses gettext.sh in a future patch series.
 
-gettext () {
-	printf "%s" "$1"
-}
+if test -z "$GIT_GETTEXT_POISON"
+then
+	gettext () {
+		printf "%s" "$1"
+	}
+
+	eval_gettext () {
+		printf "%s" "$1" | (
+			export PATH $(git sh-i18n--envsubst --variables "$1");
+			git sh-i18n--envsubst "$1"
+		)
+	}
+else
+	gettext () {
+		printf "%s" "# GETTEXT POISON #"
+	}
+
+	eval_gettext () {
+		printf "%s" "# GETTEXT POISON #"
+	}
+fi
 
-eval_gettext () {
-	printf "%s" "$1" | (
-		export PATH $(git sh-i18n--envsubst --variables "$1");
-		git sh-i18n--envsubst "$1"
-	)
-}
-- 
1.7.4.4

  parent reply	other threads:[~2011-05-14 13:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-14 13:47 [PATCH v2 0/4] i18n: Add shell script translation infrastructure Ævar Arnfjörð Bjarmason
2011-05-14 13:47 ` [PATCH v2 1/4] git-sh-i18n--envsubst: our own envsubst(1) for eval_gettext() Ævar Arnfjörð Bjarmason
2011-05-15  3:30   ` Junio C Hamano
2011-05-14 13:47 ` [PATCH v2 2/4] git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers Ævar Arnfjörð Bjarmason
2011-05-14 13:47 ` Ævar Arnfjörð Bjarmason [this message]
2011-05-14 13:47 ` [PATCH v2 4/4] Makefile: add xgettext target for *.sh files Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305380865-21339-4-git-send-email-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).