i18n: mark checkout plural warning for translation
Mark the "Warning: you are leaving %d commit(s) behind" message added in v1.7.5-rc0~74^2 (commit: give final warning when reattaching HEAD to leave commits behind) by Junio C Hamano for translation. This message requires the use of ngettext() features, and is the first message to use the Q_() wrapper around ngettext(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Apr 10, 2011 at 19:34 UTC
f06f08b78c1c8be7039bd94c5f1fb305812fda34
2 files changed
+27
-6
builtin/checkout.c
+15
-3
@@ -648,18 +648,30 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
648
if (more == 1)
649
describe_one_orphan(&sb, last);
650
else
651
- strbuf_addf(&sb, " ... and %d more.\n", more);
651
+ strbuf_addf(&sb, _(" ... and %d more.\n"), more);
652
}
653
654
fprintf(stderr,
655
- "Warning: you are leaving %d commit%s behind, "
655
+ Q_(
656
+ /* The singular version */
657
+ "Warning: you are leaving %d commit behind, "
658
+ "not connected to\n"
659
+ "any of your branches:\n\n"
660
+ "%s\n"
661
+ "If you want to keep it by creating a new branch, "
662
+ "this may be a good time\nto do so with:\n\n"
663
+ " git branch new_branch_name %s\n\n",
664
+ /* The plural version */
665
+ "Warning: you are leaving %d commits behind, "
666
"not connected to\n"
667
"any of your branches:\n\n"
668
"%s\n"
669
"If you want to keep them by creating a new branch, "
670
"this may be a good time\nto do so with:\n\n"
671
" git branch new_branch_name %s\n\n",
662
- lost, ((1 < lost) ? "s" : ""),
672
+ /* Give ngettext() the count */
673
+ lost),
674
+ lost,
675
sb.buf,
676
sha1_to_hex(commit->object.sha1));
677
strbuf_release(&sb);
t/t2020-checkout-detach.sh
+12
-3
@@ -108,21 +108,30 @@ test_expect_success 'checkout warns on orphan commits' '
108
echo content >orphan &&
109
git add orphan &&
110
git commit -a -m orphan &&
111
- git checkout master 2>stderr &&
111
+ git checkout master 2>stderr
112
+'
113
+
114
+test_expect_success C_LOCALE_OUTPUT 'checkout warns on orphan commits: output' '
115
check_orphan_warning stderr
116
'
117
118
test_expect_success 'checkout does not warn leaving ref tip' '
119
reset &&
120
git checkout --detach two &&
118
- git checkout master 2>stderr &&
121
+ git checkout master 2>stderr
122
+'
123
+
124
+test_expect_success C_LOCALE_OUTPUT 'checkout does not warn leaving ref tip' '
125
check_no_orphan_warning stderr
126
'
127
128
test_expect_success 'checkout does not warn leaving reachable commit' '
129
reset &&
130
git checkout --detach HEAD^ &&
125
- git checkout master 2>stderr &&
131
+ git checkout master 2>stderr
132
+'
133
+
134
+test_expect_success C_LOCALE_OUTPUT 'checkout does not warn leaving reachable commit' '
135
check_no_orphan_warning stderr
136
'
137