Skip to content

Commit f06f08b

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 20fc73e commit f06f08b

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

builtin/checkout.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,18 +648,30 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
648648
if (more == 1)
649649
describe_one_orphan(&sb, last);
650650
else
651-
strbuf_addf(&sb, " ... and %d more.\n", more);
651+
strbuf_addf(&sb, _(" ... and %d more.\n"), more);
652652
}
653653

654654
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, "
656666
"not connected to\n"
657667
"any of your branches:\n\n"
658668
"%s\n"
659669
"If you want to keep them by creating a new branch, "
660670
"this may be a good time\nto do so with:\n\n"
661671
" git branch new_branch_name %s\n\n",
662-
lost, ((1 < lost) ? "s" : ""),
672+
/* Give ngettext() the count */
673+
lost),
674+
lost,
663675
sb.buf,
664676
sha1_to_hex(commit->object.sha1));
665677
strbuf_release(&sb);

t/t2020-checkout-detach.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,30 @@ test_expect_success 'checkout warns on orphan commits' '
108108
echo content >orphan &&
109109
git add orphan &&
110110
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' '
112115
check_orphan_warning stderr
113116
'
114117

115118
test_expect_success 'checkout does not warn leaving ref tip' '
116119
reset &&
117120
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' '
119125
check_no_orphan_warning stderr
120126
'
121127

122128
test_expect_success 'checkout does not warn leaving reachable commit' '
123129
reset &&
124130
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' '
126135
check_no_orphan_warning stderr
127136
'
128137

0 commit comments

Comments
 (0)