i18n: apply: update say_patch_name to give translators complete sentence
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Apr 23, 2012 at 19:30 UTC
5613e8117d4c2093e1abfc10f9ccbe173a1b405f
1 file changed
+20
-12
builtin/apply.c
+20
-12
@@ -335,22 +335,25 @@ static void clear_image(struct image *image)
335
image->len = 0;
336
}
337
338
-static void say_patch_name(FILE *output, const char *pre,
339
- struct patch *patch, const char *post)
338
+/* fmt must contain _one_ %s and no other substitution */
339
+static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
340
{
341
- fputs(pre, output);
341
+ struct strbuf sb = STRBUF_INIT;
342
+
343
if (patch->old_name && patch->new_name &&
344
strcmp(patch->old_name, patch->new_name)) {
344
- quote_c_style(patch->old_name, NULL, output, 0);
345
- fputs(" => ", output);
346
- quote_c_style(patch->new_name, NULL, output, 0);
345
+ quote_c_style(patch->old_name, &sb, NULL, 0);
346
+ strbuf_addstr(&sb, " => ");
347
+ quote_c_style(patch->new_name, &sb, NULL, 0);
348
} else {
349
const char *n = patch->new_name;
350
if (!n)
351
n = patch->old_name;
351
- quote_c_style(n, NULL, output, 0);
352
+ quote_c_style(n, &sb, NULL, 0);
353
}
353
- fputs(post, output);
354
+ fprintf(output, fmt, sb.buf);
355
+ fputc('\n', output);
356
+ strbuf_release(&sb);
357
}
358
359
#define CHUNKSIZE (8192)
@@ -3172,7 +3175,7 @@ static int check_patch_list(struct patch *patch)
3175
while (patch) {
3176
if (apply_verbosely)
3177
say_patch_name(stderr,
3175
- "Checking patch ", patch, "...\n");
3178
+ _("Checking patch %s..."), patch);
3179
err |= check_patch(patch);
3180
patch = patch->next;
3181
}
@@ -3536,6 +3539,7 @@ static int write_out_one_reject(struct patch *patch)
3539
char namebuf[PATH_MAX];
3540
struct fragment *frag;
3541
int cnt = 0;
3542
+ struct strbuf sb = STRBUF_INIT;
3543
3544
for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
3545
if (!frag->rejected)
@@ -3546,7 +3550,7 @@ static int write_out_one_reject(struct patch *patch)
3550
if (!cnt) {
3551
if (apply_verbosely)
3552
say_patch_name(stderr,
3549
- "Applied patch ", patch, " cleanly.\n");
3553
+ _("Applied patch %s cleanly."), patch);
3554
return 0;
3555
}
3556
@@ -3557,8 +3561,12 @@ static int write_out_one_reject(struct patch *patch)
3561
die(_("internal error"));
3562
3563
/* Say this even without --verbose */
3560
- say_patch_name(stderr, "Applying patch ", patch, " with");
3561
- fprintf(stderr, " %d rejects...\n", cnt);
3564
+ strbuf_addf(&sb, Q_("Applying patch %%s with %d reject...",
3565
+ "Applying patch %%s with %d rejects...",
3566
+ cnt),
3567
+ cnt);
3568
+ say_patch_name(stderr, sb.buf, patch);
3569
+ strbuf_release(&sb);
3570
3571
cnt = strlen(patch->new_name);
3572
if (ARRAY_SIZE(namebuf) <= cnt + 5) {