402
esac
403
}
404
405
-nth_string () {
406
- case "$1" in
407
- *1[0-9]|*[04-9]) echo "$1"th;;
408
- *1) echo "$1"st;;
409
- *2) echo "$1"nd;;
410
- *3) echo "$1"rd;;
405
+this_nth_commit_message () {
406
+ n=$1
407
+ case "$n" in
408
+ 1) gettext "This is the 1st commit message:";;
409
+ 2) gettext "This is the 2nd commit message:";;
410
+ 3) gettext "This is the 3rd commit message:";;
411
+ 4) gettext "This is the 4th commit message:";;
412
+ 5) gettext "This is the 5th commit message:";;
413
+ 6) gettext "This is the 6th commit message:";;
414
+ 7) gettext "This is the 7th commit message:";;
415
+ 8) gettext "This is the 8th commit message:";;
416
+ 9) gettext "This is the 9th commit message:";;
417
+ 10) gettext "This is the 10th commit message:";;
418
+ # TRANSLATORS: if the language you are translating into
419
+ # doesn't allow you to compose a sentence in this fashion,
420
+ # consider translating as if this and the following few strings
421
+ # were "This is the commit message ${n}:"
422
+ *1[0-9]|*[04-9]) eval_gettext "This is the \${n}th commit message:";;
423
+ *1) eval_gettext "This is the \${n}st commit message:";;
424
+ *2) eval_gettext "This is the \${n}nd commit message:";;
425
+ *3) eval_gettext "This is the \${n}rd commit message:";;
426
+ *) eval_gettext "This is the commit message \${n}:";;
427
+ esac
428
+}
429
+skip_nth_commit_message () {
430
+ n=$1
431
+ case "$n" in
432
+ 1) gettext "The 1st commit message will be skipped:";;
433
+ 2) gettext "The 2nd commit message will be skipped:";;
434
+ 3) gettext "The 3rd commit message will be skipped:";;
435
+ 4) gettext "The 4th commit message will be skipped:";;
436
+ 5) gettext "The 5th commit message will be skipped:";;
437
+ 6) gettext "The 6th commit message will be skipped:";;
438
+ 7) gettext "The 7th commit message will be skipped:";;
439
+ 8) gettext "The 8th commit message will be skipped:";;
440
+ 9) gettext "The 9th commit message will be skipped:";;
441
+ 10) gettext "The 10th commit message will be skipped:";;
442
+ # TRANSLATORS: if the language you are translating into
443
+ # doesn't allow you to compose a sentence in this fashion,
444
+ # consider translating as if this and the following few strings
445
+ # were "The commit message ${n} will be skipped:"
446
+ *1[0-9]|*[04-9]) eval_gettext "The \${n}th commit message will be skipped:";;
447
+ *1) eval_gettext "The \${n}st commit message will be skipped:";;
448
+ *2) eval_gettext "The \${n}nd commit message will be skipped:";;
449
+ *3) eval_gettext "The \${n}rd commit message will be skipped:";;
450
+ *) eval_gettext "The commit message \${n} will be skipped:";;
451
esac
452
}
453
455
if test -f "$squash_msg"; then
456
mv "$squash_msg" "$squash_msg".bak || exit
457
count=$(($(sed -n \
418
- -e "1s/^. This is a combination of \(.*\) commits\./\1/p" \
458
+ -e "1s/^$comment_char.*\([0-9][0-9]*\).*/\1/p" \
459
-e "q" < "$squash_msg".bak)+1))
460
{
421
- printf '%s\n' "$comment_char This is a combination of $count commits."
461
+ printf '%s\n' "$comment_char $(eval_ngettext \
462
+ "This is a combination of \$count commit." \
463
+ "This is a combination of \$count commits." \
464
+ $count)"
465
sed -e 1d -e '2,/^./{
466
/^$/d
467
}' <"$squash_msg".bak
468
} >"$squash_msg"
469
else
427
- commit_message HEAD > "$fixup_msg" || die "Cannot write $fixup_msg"
470
+ commit_message HEAD > "$fixup_msg" || die "$(gettext "Cannot write \$fixup_msg")"
471
count=2
472
{
430
- printf '%s\n' "$comment_char This is a combination of 2 commits."
431
- printf '%s\n' "$comment_char The first commit's message is:"
473
+ printf '%s\n' "$comment_char $(gettext "This is a combination of 2 commits.")"
474
+ printf '%s\n' "$comment_char $(gettext "This is the 1st commit message:")"
475
echo
476
cat "$fixup_msg"
477
} >"$squash_msg"
480
squash)
481
rm -f "$fixup_msg"
482
echo
440
- printf '%s\n' "$comment_char This is the $(nth_string $count) commit message:"
483
+ printf '%s\n' "$comment_char $(this_nth_commit_message $count)"
484
echo
485
commit_message $2
486
;;
487
fixup)
488
echo
446
- printf '%s\n' "$comment_char The $(nth_string $count) commit message will be skipped:"
489
+ printf '%s\n' "$comment_char $(skip_nth_commit_message $count)"
490
echo
491
# Change the space after the comment character to TAB:
492
commit_message $2 | git stripspace --comment-lines | sed -e 's/ / /'