i18n: rebase-interactive: mark comments of squash for translation
Mark comment messages of squash/fixup file ($squash_msg) for translation. Helper functions this_nth_commit_message and skip_nth_commit_message replace the previous method of making the comment messages (such as "This is the 2nd commit message:") aided by nth_string helper function. This step was taken as a workaround to enabled translation of entire sentences. However, doesn't change any text seen in English by the user, except for string "The first commit's message is:" which was changed to match the style of other instances. The test t3404-rebase-interactive.sh resorts to set_fake_editor which didn't account for GETTEXT_POISON. Fix it by assuming success when we find dummy gettext poison output where was supposed to find the first comment line "This is a combination of $count commits.". For that same message, use plural aware eval_ngettext instead of eval_gettext, since other languages have more complex plural forms. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b8fc9e43a7
commit
f2d17068fd
@ -402,12 +402,52 @@ pick_one_preserving_merges () {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nth_string () {
|
this_nth_commit_message () {
|
||||||
case "$1" in
|
n=$1
|
||||||
*1[0-9]|*[04-9]) echo "$1"th;;
|
case "$n" in
|
||||||
*1) echo "$1"st;;
|
1) gettext "This is the 1st commit message:";;
|
||||||
*2) echo "$1"nd;;
|
2) gettext "This is the 2nd commit message:";;
|
||||||
*3) echo "$1"rd;;
|
3) gettext "This is the 3rd commit message:";;
|
||||||
|
4) gettext "This is the 4th commit message:";;
|
||||||
|
5) gettext "This is the 5th commit message:";;
|
||||||
|
6) gettext "This is the 6th commit message:";;
|
||||||
|
7) gettext "This is the 7th commit message:";;
|
||||||
|
8) gettext "This is the 8th commit message:";;
|
||||||
|
9) gettext "This is the 9th commit message:";;
|
||||||
|
10) gettext "This is the 10th commit message:";;
|
||||||
|
# TRANSLATORS: if the language you are translating into
|
||||||
|
# doesn't allow you to compose a sentence in this fashion,
|
||||||
|
# consider translating as if this and the following few strings
|
||||||
|
# were "This is the commit message ${n}:"
|
||||||
|
*1[0-9]|*[04-9]) eval_gettext "This is the \${n}th commit message:";;
|
||||||
|
*1) eval_gettext "This is the \${n}st commit message:";;
|
||||||
|
*2) eval_gettext "This is the \${n}nd commit message:";;
|
||||||
|
*3) eval_gettext "This is the \${n}rd commit message:";;
|
||||||
|
*) eval_gettext "This is the commit message \${n}:";;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
skip_nth_commit_message () {
|
||||||
|
n=$1
|
||||||
|
case "$n" in
|
||||||
|
1) gettext "The 1st commit message will be skipped:";;
|
||||||
|
2) gettext "The 2nd commit message will be skipped:";;
|
||||||
|
3) gettext "The 3rd commit message will be skipped:";;
|
||||||
|
4) gettext "The 4th commit message will be skipped:";;
|
||||||
|
5) gettext "The 5th commit message will be skipped:";;
|
||||||
|
6) gettext "The 6th commit message will be skipped:";;
|
||||||
|
7) gettext "The 7th commit message will be skipped:";;
|
||||||
|
8) gettext "The 8th commit message will be skipped:";;
|
||||||
|
9) gettext "The 9th commit message will be skipped:";;
|
||||||
|
10) gettext "The 10th commit message will be skipped:";;
|
||||||
|
# TRANSLATORS: if the language you are translating into
|
||||||
|
# doesn't allow you to compose a sentence in this fashion,
|
||||||
|
# consider translating as if this and the following few strings
|
||||||
|
# were "The commit message ${n} will be skipped:"
|
||||||
|
*1[0-9]|*[04-9]) eval_gettext "The \${n}th commit message will be skipped:";;
|
||||||
|
*1) eval_gettext "The \${n}st commit message will be skipped:";;
|
||||||
|
*2) eval_gettext "The \${n}nd commit message will be skipped:";;
|
||||||
|
*3) eval_gettext "The \${n}rd commit message will be skipped:";;
|
||||||
|
*) eval_gettext "The commit message \${n} will be skipped:";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,20 +455,23 @@ update_squash_messages () {
|
|||||||
if test -f "$squash_msg"; then
|
if test -f "$squash_msg"; then
|
||||||
mv "$squash_msg" "$squash_msg".bak || exit
|
mv "$squash_msg" "$squash_msg".bak || exit
|
||||||
count=$(($(sed -n \
|
count=$(($(sed -n \
|
||||||
-e "1s/^. This is a combination of \(.*\) commits\./\1/p" \
|
-e "1s/^$comment_char.*\([0-9][0-9]*\).*/\1/p" \
|
||||||
-e "q" < "$squash_msg".bak)+1))
|
-e "q" < "$squash_msg".bak)+1))
|
||||||
{
|
{
|
||||||
printf '%s\n' "$comment_char This is a combination of $count commits."
|
printf '%s\n' "$comment_char $(eval_ngettext \
|
||||||
|
"This is a combination of \$count commit." \
|
||||||
|
"This is a combination of \$count commits." \
|
||||||
|
$count)"
|
||||||
sed -e 1d -e '2,/^./{
|
sed -e 1d -e '2,/^./{
|
||||||
/^$/d
|
/^$/d
|
||||||
}' <"$squash_msg".bak
|
}' <"$squash_msg".bak
|
||||||
} >"$squash_msg"
|
} >"$squash_msg"
|
||||||
else
|
else
|
||||||
commit_message HEAD > "$fixup_msg" || die "Cannot write $fixup_msg"
|
commit_message HEAD > "$fixup_msg" || die "$(gettext "Cannot write \$fixup_msg")"
|
||||||
count=2
|
count=2
|
||||||
{
|
{
|
||||||
printf '%s\n' "$comment_char This is a combination of 2 commits."
|
printf '%s\n' "$comment_char $(gettext "This is a combination of 2 commits.")"
|
||||||
printf '%s\n' "$comment_char The first commit's message is:"
|
printf '%s\n' "$comment_char $(gettext "This is the 1st commit message:")"
|
||||||
echo
|
echo
|
||||||
cat "$fixup_msg"
|
cat "$fixup_msg"
|
||||||
} >"$squash_msg"
|
} >"$squash_msg"
|
||||||
@ -437,13 +480,13 @@ update_squash_messages () {
|
|||||||
squash)
|
squash)
|
||||||
rm -f "$fixup_msg"
|
rm -f "$fixup_msg"
|
||||||
echo
|
echo
|
||||||
printf '%s\n' "$comment_char This is the $(nth_string $count) commit message:"
|
printf '%s\n' "$comment_char $(this_nth_commit_message $count)"
|
||||||
echo
|
echo
|
||||||
commit_message $2
|
commit_message $2
|
||||||
;;
|
;;
|
||||||
fixup)
|
fixup)
|
||||||
echo
|
echo
|
||||||
printf '%s\n' "$comment_char The $(nth_string $count) commit message will be skipped:"
|
printf '%s\n' "$comment_char $(skip_nth_commit_message $count)"
|
||||||
echo
|
echo
|
||||||
# Change the space after the comment character to TAB:
|
# Change the space after the comment character to TAB:
|
||||||
commit_message $2 | git stripspace --comment-lines | sed -e 's/ / /'
|
commit_message $2 | git stripspace --comment-lines | sed -e 's/ / /'
|
||||||
|
@ -29,6 +29,7 @@ set_fake_editor () {
|
|||||||
*/COMMIT_EDITMSG)
|
*/COMMIT_EDITMSG)
|
||||||
test -z "$EXPECT_HEADER_COUNT" ||
|
test -z "$EXPECT_HEADER_COUNT" ||
|
||||||
test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
|
test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
|
||||||
|
test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" ||
|
||||||
exit
|
exit
|
||||||
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
|
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
|
||||||
test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
|
test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user