git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/5] gettext: add gettextln, eval_gettextln to encode common idiom

From
Jon Seymour <jon.seymour@gmail.com>
Date
Aug 7, 2011, 11:58 UTC
Message-ID
<1312718297-10999-2-git-send-email-jon.seymour@gmail.com>
In-Reply-To
<1312718297-10999-1-git-send-email-jon.seymour@gmail.com>

Currently, if you want to use gettext or eval_gettext to format a message you may have to add a separate echo statement and a surrounding subshell in order to interpolate the required trailing new line.

This patch introduces two new helper functions, gettextln and eval_gettextln which append a trailing newline to the gettext output.

This allows constructions of the form:
	if test -s "$GIT_DIR/BISECT_START"
	then
		(
			gettext "You need to give me at least one good and one bad revisions.
(You can use \"git bisect bad\" and \"git bisect good\" for that.)" &&
			echo
		) >&2
	else
	...
to be expressed more concisely as:
	if test -s "$GIT_DIR/BISECT_START"
	then
		gettextln "You need to give me at least one good and one bad revisions.
(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
	else
	...
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-sh-i18n.sh |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index 32ca59d..e672366 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -11,19 +11,38 @@ then
 		printf "%s" "$1"
 	}
 
+	gettextln() {
+		printf "%s\n" "$1"
+	}
+
 	eval_gettext () {
 		printf "%s" "$1" | (
 			export PATH $(git sh-i18n--envsubst --variables "$1");
 			git sh-i18n--envsubst "$1"
 		)
 	}
+
+	eval_gettextln () {
+		printf "%s\n" "$1" | (
+			export PATH $(git sh-i18n--envsubst --variables "$1");
+			git sh-i18n--envsubst "$1"
+		)
+	}
 else
 	gettext () {
 		printf "%s" "# GETTEXT POISON #"
 	}
 
+	gettextln () {
+		printf "%s\n" "# GETTEXT POISON #"
+	}
+
 	eval_gettext () {
 		printf "%s" "# GETTEXT POISON #"
 	}
+
+	eval_gettextln () {
+		printf "%s\n" "# GETTEXT POISON #"
+	}
 fi
 
-- 
1.7.6.363.g9b380.dirty
Previous: Jon SeymourNext: Jon Seymour
Message 2 of 6 in “gettext: add gettextln, eval_gettextln to encode common idiom”
  1. 0/5 gettext: add gettextln, eval_gettextln to encode common idiomJon Seymour, Aug 7, 2011
  2. 1/5 gettext: add gettextln, eval_gettextln to encode common idiomJon Seymour, Aug 7, 2011
  3. 2/5 git-am: take advantage of gettextln and eval_gettextln.Jon Seymour, Aug 7, 2011
  4. 3/5 pull: take advantage of eval_gettextlnJon Seymour, Aug 7, 2011
  5. 4/5 stash: take advantage of eval_gettextlnJon Seymour, Aug 7, 2011
  6. 5/5 submodule: take advantage of gettextln and eval_gettextln.Jon Seymour, Aug 7, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.