Skip to content

Commit b8fc9e4

Browse files
vascoolgitster
authored andcommitted
i18n: rebase-interactive: mark here-doc strings for translation
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9588c52 commit b8fc9e4

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

git-rebase--interactive.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,29 +144,28 @@ reschedule_last_action () {
144144
}
145145

146146
append_todo_help () {
147-
git stripspace --comment-lines >>"$todo" <<\EOF
148-
147+
gettext "
149148
Commands:
150149
p, pick = use commit
151150
r, reword = use commit, but edit the commit message
152151
e, edit = use commit, but stop for amending
153152
s, squash = use commit, but meld into previous commit
154-
f, fixup = like "squash", but discard this commit's log message
153+
f, fixup = like \"squash\", but discard this commit's log message
155154
x, exec = run command (the rest of the line) using shell
156155
d, drop = remove commit
157156
158157
These lines can be re-ordered; they are executed from top to bottom.
158+
" | git stripspace --comment-lines >>"$todo"
159159

160-
EOF
161160
if test $(get_missing_commit_check_level) = error
162161
then
163-
git stripspace --comment-lines >>"$todo" <<\EOF
162+
gettext "
164163
Do not remove any line. Use 'drop' explicitly to remove a commit.
165-
EOF
164+
" | git stripspace --comment-lines >>"$todo"
166165
else
167-
git stripspace --comment-lines >>"$todo" <<\EOF
166+
gettext "
168167
If you remove a line here THAT COMMIT WILL BE LOST.
169-
EOF
168+
" | git stripspace --comment-lines >>"$todo"
170169
fi
171170
}
172171

@@ -1123,13 +1122,12 @@ edit-todo)
11231122
mv -f "$todo".new "$todo"
11241123
collapse_todo_ids
11251124
append_todo_help
1126-
git stripspace --comment-lines >>"$todo" <<\EOF
1127-
1125+
gettext "
11281126
You are editing the todo file of an ongoing interactive rebase.
11291127
To continue rebase after editing, run:
11301128
git rebase --continue
11311129
1132-
EOF
1130+
" | git stripspace --comment-lines >>"$todo"
11331131

11341132
git_sequence_editor "$todo" ||
11351133
die "$(gettext "Could not execute editor")"
@@ -1270,14 +1268,16 @@ todocount=${todocount##* }
12701268

12711269
cat >>"$todo" <<EOF
12721270
1273-
$comment_char Rebase $shortrevisions onto $shortonto ($todocount command(s))
1271+
$comment_char $(eval_ngettext \
1272+
"Rebase \$shortrevisions onto \$shortonto (\$todocount command)" \
1273+
"Rebase \$shortrevisions onto \$shortonto (\$todocount commands)" \
1274+
"$todocount")
12741275
EOF
12751276
append_todo_help
1276-
git stripspace --comment-lines >>"$todo" <<\EOF
1277-
1277+
gettext "
12781278
However, if you remove everything, the rebase will be aborted.
12791279
1280-
EOF
1280+
" | git stripspace --comment-lines >>"$todo"
12811281

12821282
if test -z "$keep_empty"
12831283
then

git-sh-i18n.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ gettext_without_eval_gettext)
5353
git sh-i18n--envsubst "$1"
5454
)
5555
}
56+
57+
eval_ngettext () {
58+
ngettext "$1" "$2" "$3" | (
59+
export PATH $(git sh-i18n--envsubst --variables "$2");
60+
git sh-i18n--envsubst "$2"
61+
)
62+
}
5663
;;
5764
poison)
5865
# Emit garbage so that tests that incorrectly rely on translatable
@@ -64,6 +71,10 @@ poison)
6471
eval_gettext () {
6572
printf "%s" "# GETTEXT POISON #"
6673
}
74+
75+
eval_ngettext () {
76+
printf "%s" "# GETTEXT POISON #"
77+
}
6778
;;
6879
*)
6980
gettext () {
@@ -76,6 +87,13 @@ poison)
7687
git sh-i18n--envsubst "$1"
7788
)
7889
}
90+
91+
eval_ngettext () {
92+
(test "$3" = 1 && printf "%s" "$1" || printf "%s" "$2") | (
93+
export PATH $(git sh-i18n--envsubst --variables "$2");
94+
git sh-i18n--envsubst "$2"
95+
)
96+
}
7997
;;
8098
esac
8199

t/t3404-rebase-interactive.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ test_expect_success 'clean error after failed "exec"' '
540540
echo "edited again" > file7 &&
541541
git add file7 &&
542542
test_must_fail git rebase --continue 2>error &&
543-
grep "You have staged changes in your working tree." error
543+
test_i18ngrep "You have staged changes in your working tree." error
544544
'
545545

546546
test_expect_success 'rebase a detached HEAD' '
@@ -1060,7 +1060,7 @@ test_expect_success 'todo count' '
10601060
EOF
10611061
test_set_editor "$(pwd)/dump-raw.sh" &&
10621062
git rebase -i HEAD~4 >actual &&
1063-
grep "^# Rebase ..* onto ..* ([0-9]" actual
1063+
test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
10641064
'
10651065

10661066
test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
@@ -1160,7 +1160,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
11601160
FAKE_LINES="1 2 3 4" \
11611161
git rebase -i --root 2>actual &&
11621162
test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1163-
test_cmp expect actual
1163+
test_i18ncmp expect actual
11641164
'
11651165

11661166
cat >expect <<EOF
@@ -1181,7 +1181,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
11811181
set_fake_editor &&
11821182
FAKE_LINES="1 2 3 4" \
11831183
git rebase -i --root 2>actual &&
1184-
test_cmp expect actual &&
1184+
test_i18ncmp expect actual &&
11851185
test D = $(git cat-file commit HEAD | sed -ne \$p)
11861186
'
11871187

@@ -1205,7 +1205,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
12051205
set_fake_editor &&
12061206
test_must_fail env FAKE_LINES="1 2 4" \
12071207
git rebase -i --root 2>actual &&
1208-
test_cmp expect actual &&
1208+
test_i18ncmp expect actual &&
12091209
cp .git/rebase-merge/git-rebase-todo.backup \
12101210
.git/rebase-merge/git-rebase-todo &&
12111211
FAKE_LINES="1 2 drop 3 4 drop 5" \
@@ -1228,7 +1228,7 @@ test_expect_success 'static check of bad command' '
12281228
set_fake_editor &&
12291229
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
12301230
git rebase -i --root 2>actual &&
1231-
test_cmp expect actual &&
1231+
test_i18ncmp expect actual &&
12321232
FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
12331233
git rebase --continue &&
12341234
test E = $(git cat-file commit HEAD | sed -ne \$p) &&
@@ -1263,7 +1263,7 @@ test_expect_success 'static check of bad SHA-1' '
12631263
set_fake_editor &&
12641264
test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
12651265
git rebase -i --root 2>actual &&
1266-
test_cmp expect actual &&
1266+
test_i18ncmp expect actual &&
12671267
FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
12681268
git rebase --continue &&
12691269
test E = $(git cat-file commit HEAD | sed -ne \$p)

0 commit comments

Comments
 (0)