Skip to content

Commit 3da5c54

Browse files
jonseymourgitster
authored andcommitted
gettext: add gettextln, eval_gettextln to encode common idiom
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 <[email protected]> Signed-off-by: Jon Seymour <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e7a85be commit 3da5c54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

git-sh-i18n.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ then
1111
printf "%s" "$1"
1212
}
1313

14+
gettextln() {
15+
printf "%s\n" "$1"
16+
}
17+
1418
eval_gettext () {
1519
printf "%s" "$1" | (
1620
export PATH $(git sh-i18n--envsubst --variables "$1");
1721
git sh-i18n--envsubst "$1"
1822
)
1923
}
24+
25+
eval_gettextln () {
26+
printf "%s\n" "$1" | (
27+
export PATH $(git sh-i18n--envsubst --variables "$1");
28+
git sh-i18n--envsubst "$1"
29+
)
30+
}
2031
else
2132
gettext () {
2233
printf "%s" "# GETTEXT POISON #"
2334
}
2435

36+
gettextln () {
37+
printf "%s\n" "# GETTEXT POISON #"
38+
}
39+
2540
eval_gettext () {
2641
printf "%s" "# GETTEXT POISON #"
2742
}
43+
44+
eval_gettextln () {
45+
printf "%s\n" "# GETTEXT POISON #"
46+
}
2847
fi
2948

0 commit comments

Comments
 (0)