git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Vasco Almeida <vascomalmeida@sapo.pt>
To: git@vger.kernel.org
Cc: "Vasco Almeida" <vascomalmeida@sapo.pt>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	Sunshine <sunshine@sunshineco.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v4 15/38] i18n: rebase-interactive: mark here-doc strings for translation
Date: Tue,  7 Jun 2016 11:52:14 +0000	[thread overview]
Message-ID: <1465300357-7557-16-git-send-email-vascomalmeida@sapo.pt> (raw)
In-Reply-To: <1465300357-7557-1-git-send-email-vascomalmeida@sapo.pt>

Use pipe to send gettext output to git stripspace instead of the
original method of using shell here-document, because command
substitution '$(...)' would not take place inside the here-documents.
The exception is the case of the last here-document redirecting to cat,
in which commands substitution works and, thus, is preserved in this
commit.

t3404: adapt test to the strings newly marked for translation
Test t3404-rebase-interactive.sh would fail under GETTEXT_POISON unless
using test_i18ngrep.

Add eval_ngettext fallback functions to be called when running, for
instance, under GETTEXT_POISON. Otherwise, tests would fail under
GETTEXT_POISON, or other build that doesn't support the GNU gettext,
because that function could not be found.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-rebase--interactive.sh    | 30 +++++++++++++++---------------
 git-sh-i18n.sh                | 18 ++++++++++++++++++
 t/t3404-rebase-interactive.sh | 14 +++++++-------
 3 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 2b8a845..a16ce3a 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -144,29 +144,28 @@ reschedule_last_action () {
 }
 
 append_todo_help () {
-	git stripspace --comment-lines >>"$todo" <<\EOF
-
+	gettext "
 Commands:
  p, pick = use commit
  r, reword = use commit, but edit the commit message
  e, edit = use commit, but stop for amending
  s, squash = use commit, but meld into previous commit
- f, fixup = like "squash", but discard this commit's log message
+ f, fixup = like \"squash\", but discard this commit's log message
  x, exec = run command (the rest of the line) using shell
  d, drop = remove commit
 
 These lines can be re-ordered; they are executed from top to bottom.
+" | git stripspace --comment-lines >>"$todo"
 
-EOF
 	if test $(get_missing_commit_check_level) = error
 	then
-		git stripspace --comment-lines >>"$todo" <<\EOF
+		gettext "
 Do not remove any line. Use 'drop' explicitly to remove a commit.
-EOF
+" | git stripspace --comment-lines >>"$todo"
 	else
-		git stripspace --comment-lines >>"$todo" <<\EOF
+		gettext "
 If you remove a line here THAT COMMIT WILL BE LOST.
-EOF
+" | git stripspace --comment-lines >>"$todo"
 	fi
 }
 
@@ -1122,13 +1121,12 @@ edit-todo)
 	mv -f "$todo".new "$todo"
 	collapse_todo_ids
 	append_todo_help
-	git stripspace --comment-lines >>"$todo" <<\EOF
-
+	gettext "
 You are editing the todo file of an ongoing interactive rebase.
 To continue rebase after editing, run:
     git rebase --continue
 
-EOF
+" | git stripspace --comment-lines >>"$todo"
 
 	git_sequence_editor "$todo" ||
 		die "$(gettext "Could not execute editor")"
@@ -1269,14 +1267,16 @@ todocount=${todocount##* }
 
 cat >>"$todo" <<EOF
 
-$comment_char Rebase $shortrevisions onto $shortonto ($todocount command(s))
+$comment_char $(eval_ngettext \
+	"Rebase \$shortrevisions onto \$shortonto (\$todocount command)" \
+	"Rebase \$shortrevisions onto \$shortonto (\$todocount commands)" \
+	"$todocount")
 EOF
 append_todo_help
-git stripspace --comment-lines >>"$todo" <<\EOF
-
+gettext "
 However, if you remove everything, the rebase will be aborted.
 
-EOF
+" | git stripspace --comment-lines >>"$todo"
 
 if test -z "$keep_empty"
 then
diff --git a/git-sh-i18n.sh b/git-sh-i18n.sh
index e6c3116..1ef1889 100644
--- a/git-sh-i18n.sh
+++ b/git-sh-i18n.sh
@@ -53,6 +53,13 @@ gettext_without_eval_gettext)
 			git sh-i18n--envsubst "$1"
 		)
 	}
+
+	eval_ngettext () {
+		ngettext "$1" "$2" "$3" | (
+			export PATH $(git sh-i18n--envsubst --variables "$2");
+			git sh-i18n--envsubst "$2"
+		)
+	}
 	;;
 poison)
 	# Emit garbage so that tests that incorrectly rely on translatable
@@ -64,6 +71,10 @@ poison)
 	eval_gettext () {
 		printf "%s" "# GETTEXT POISON #"
 	}
+
+	eval_ngettext () {
+		printf "%s" "# GETTEXT POISON #"
+	}
 	;;
 *)
 	gettext () {
@@ -76,6 +87,13 @@ poison)
 			git sh-i18n--envsubst "$1"
 		)
 	}
+
+	eval_ngettext () {
+		(test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
+			export PATH $(git sh-i18n--envsubst --variables "$2");
+			git sh-i18n--envsubst "$2"
+		)
+	}
 	;;
 esac
 
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 66348f1..f4ccd10 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -540,7 +540,7 @@ test_expect_success 'clean error after failed "exec"' '
 	echo "edited again" > file7 &&
 	git add file7 &&
 	test_must_fail git rebase --continue 2>error &&
-	grep "You have staged changes in your working tree." error
+	test_i18ngrep "You have staged changes in your working tree." error
 '
 
 test_expect_success 'rebase a detached HEAD' '
@@ -1060,7 +1060,7 @@ test_expect_success 'todo count' '
 	EOF
 	test_set_editor "$(pwd)/dump-raw.sh" &&
 	git rebase -i HEAD~4 >actual &&
-	grep "^# Rebase ..* onto ..* ([0-9]" actual
+	test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
 '
 
 test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
@@ -1160,7 +1160,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
 	FAKE_LINES="1 2 3 4" \
 		git rebase -i --root 2>actual &&
 	test D = $(git cat-file commit HEAD | sed -ne \$p) &&
-	test_cmp expect actual
+	test_i18ncmp expect actual
 '
 
 cat >expect <<EOF
@@ -1181,7 +1181,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
 	set_fake_editor &&
 	FAKE_LINES="1 2 3 4" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ncmp expect actual &&
 	test D = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
@@ -1205,7 +1205,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 4" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ncmp expect actual &&
 	cp .git/rebase-merge/git-rebase-todo.backup \
 		.git/rebase-merge/git-rebase-todo &&
 	FAKE_LINES="1 2 drop 3 4 drop 5" \
@@ -1228,7 +1228,7 @@ test_expect_success 'static check of bad command' '
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ncmp expect actual &&
 	FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
 	git rebase --continue &&
 	test E = $(git cat-file commit HEAD | sed -ne \$p) &&
@@ -1263,7 +1263,7 @@ test_expect_success 'static check of bad SHA-1' '
 	set_fake_editor &&
 	test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
 		git rebase -i --root 2>actual &&
-	test_cmp expect actual &&
+	test_i18ncmp expect actual &&
 	FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
 	git rebase --continue &&
 	test E = $(git cat-file commit HEAD | sed -ne \$p)
-- 
2.7.3

  parent reply	other threads:[~2016-06-07 11:54 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07 11:51 [PATCH v4 00/38] i18n and test updates Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 01/38] i18n: builtin/remote.c: fix mark for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 02/38] i18n: advice: mark string about detached head " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 03/38] i18n: advice: internationalize message for conflicts Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 04/38] i18n: transport: mark strings for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 05/38] i18n: sequencer: mark entire sentences " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 06/38] i18n: sequencer: mark string " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 07/38] i18n: merge-octopus: mark messages " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 08/38] merge-octupus: use die shell function from git-sh-setup.sh Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 09/38] i18n: rebase: fix marked string to use eval_gettext variant Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 10/38] i18n: rebase: mark placeholder for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 11/38] i18n: bisect: simplify error message for i18n Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 12/38] t6030: update to use test_i18ncmp Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 13/38] i18n: git-sh-setup.sh: mark strings for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 14/38] i18n: rebase-interactive: " Vasco Almeida
2016-06-07 11:52 ` Vasco Almeida [this message]
2016-06-07 11:52 ` [PATCH v4 16/38] i18n: rebase-interactive: mark comments of squash " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 17/38] i18n: setup: mark strings " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 18/38] tests: use test_i18n* functions to suppress false positives Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 19/38] tests: unpack-trees: update to use test_i18n* functions Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 20/38] t9003: become resilient to GETTEXT_POISON Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 21/38] t4153: fix negated test_i18ngrep call Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 22/38] t5523: use test_i18ngrep for negation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 23/38] i18n: bisect: mark strings for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 24/38] i18n: transport-helper.c: change N_() call to _() Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 25/38] i18n: notes: mark strings for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 26/38] i18n: notes: mark options " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 27/38] i18n: config: unfold error messages marked " Vasco Almeida
2016-06-07 22:25   ` Junio C Hamano
2016-06-07 11:52 ` [PATCH v4 28/38] i18n: merge: mark messages " Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 29/38] i18n: merge: change command option help to lowercase Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 30/38] i18n: sequencer: add period to error message Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 31/38] i18n: standardise messages Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 32/38] i18n: remote: mark URL fallback text for translation Vasco Almeida
2016-06-07 11:52 ` [PATCH v4 33/38] i18n: remote: allow translations to reorder message Vasco Almeida
2016-06-07 12:55 ` [PATCH v4 34/38] i18n: init-db: join message pieces Vasco Almeida
2016-06-17 17:41   ` Vasco Almeida
2016-06-07 12:55 ` [PATCH v4 35/38] i18n: submodule: join strings marked for translation Vasco Almeida
2016-06-07 12:55 ` [PATCH v4 36/38] i18n: submodule: escape shell variables inside eval_gettext Vasco Almeida
2016-06-07 12:55 ` [PATCH v4 37/38] i18n: unmark die messages for translation Vasco Almeida
2016-06-07 22:07   ` Junio C Hamano
2016-06-08 11:51     ` Pranit Bauva
2016-06-07 12:55 ` [PATCH v4 38/38] i18n: branch: mark comment when editing branch description " Vasco Almeida

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1465300357-7557-16-git-send-email-vascomalmeida@sapo.pt \
    --to=vascomalmeida@sapo.pt \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sunshine@sunshineco.com \
    --cc=worldhello.net@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).