git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence

From
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date
Apr 22, 2012, 16:42 UTC
Message-ID
<4F9434F1.9000900@in.waw.pl>
In-Reply-To
<1334580603-11577-10-git-send-email-pclouds@gmail.com>
On 04/16/2012 02:50 PM, Nguyễn Thái Ngọc Duy wrote:
Show 79 quoted lines
> ---
>  builtin/apply.c |   33 +++++++++++++++++++--------------
>  1 files changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/builtin/apply.c b/builtin/apply.c
> index 6e9a02e..87922cf 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -335,22 +335,25 @@ static void clear_image(struct image *image)
>  	image->len = 0;
>  }
>  
> -static void say_patch_name(FILE *output, const char *pre,
> -			   struct patch *patch, const char *post)
> +/* fmt must contain _one_ %s and no other substitution */
> +static void say_patch_name(FILE *output, struct patch *patch, const char *fmt)
>  {
> -	fputs(pre, output);
> +	struct strbuf sb = STRBUF_INIT;
> +
>  	if (patch->old_name && patch->new_name &&
>  	    strcmp(patch->old_name, patch->new_name)) {
> -		quote_c_style(patch->old_name, NULL, output, 0);
> -		fputs(" => ", output);
> -		quote_c_style(patch->new_name, NULL, output, 0);
> +		quote_c_style(patch->old_name, &sb, NULL, 0);
> +		strbuf_addstr(&sb, " => ");
> +		quote_c_style(patch->new_name, &sb, NULL, 0);
>  	} else {
>  		const char *n = patch->new_name;
>  		if (!n)
>  			n = patch->old_name;
> -		quote_c_style(n, NULL, output, 0);
> +		quote_c_style(n, &sb, NULL, 0);
>  	}
> -	fputs(post, output);
> +	fprintf(output, fmt, sb.buf);
> +	fprintf(output, "\n");
> +	strbuf_release(&sb);
>  }
>  
>  #define CHUNKSIZE (8192)
> @@ -3165,8 +3168,8 @@ static int check_patch_list(struct patch *patch)
>  	prepare_fn_table(patch);
>  	while (patch) {
>  		if (apply_verbosely)
> -			say_patch_name(stderr,
> -				       "Checking patch ", patch, "...\n");
> +			say_patch_name(stderr, patch,
> +				       _("Checking patch %s..."));
>  		err |= check_patch(patch);
>  		patch = patch->next;
>  	}
> @@ -3530,6 +3533,7 @@ static int write_out_one_reject(struct patch *patch)
>  	char namebuf[PATH_MAX];
>  	struct fragment *frag;
>  	int cnt = 0;
> +	struct strbuf sb = STRBUF_INIT;
>  
>  	for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
>  		if (!frag->rejected)
> @@ -3539,8 +3543,8 @@ static int write_out_one_reject(struct patch *patch)
>  
>  	if (!cnt) {
>  		if (apply_verbosely)
> -			say_patch_name(stderr,
> -				       "Applied patch ", patch, " cleanly.\n");
> +			say_patch_name(stderr, patch,
> +				       _("Applied patch %s cleanly."));
>  		return 0;
>  	}
>  
> @@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)
>  		die(_("internal error"));
>  
>  	/* Say this even without --verbose */
> -	say_patch_name(stderr, "Applying patch ", patch, " with");
> -	fprintf(stderr, " %d rejects...\n", cnt);
> +	strbuf_addf(&sb, _("Applying patch %%s with %d rejects..."), cnt);
Shouldn't this part be:
        strbuf_addf(&sb, Q_("Applying patch %%s with one reject...",
                            "Applying patch %%s with %d rejects...",
                            cnt), cnt);
?

- Zbyszek

Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 16 of 21 in “Mark more strings for translation”
  1. 00/11 Mark more strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  2. 01/11 Add three convenient format printing functions with \n automatically appendedNguyễn Thái Ngọc Duy, Apr 16, 2012
  3. Jonathan NiederApr 16, 2012
  4. Erik Faye-LundApr 17, 2012
  5. 02/11 i18n: mark relative dates for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  6. 03/11 i18n: parseopt: lookup help and argument translations when showing usageNguyễn Thái Ngọc Duy, Apr 16, 2012
  7. Jonathan NiederApr 16, 2012
  8. Jonathan NiederApr 16, 2012
  9. 04/11 i18n: help: mark parseopt strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  10. 05/11 i18n: help: mark strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  11. Jonathan NiederApr 18, 2012
  12. 06/11 i18n: make warn_dangling_symref() automatically append \nNguyễn Thái Ngọc Duy, Apr 16, 2012
  13. 07/11 i18n: remote: mark strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  14. 08/11 i18n: apply: mark strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  15. 09/11 i18n: apply: update say_patch_name to give translators complete sentenceNguyễn Thái Ngọc Duy, Apr 16, 2012
  16. Zbigniew Jędrzejewski-SzmekApr 22, 2012
  17. Nguyen Thai Ngoc DuyApr 23, 2012
  18. 10/11 i18n: index-pack: mark strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  19. 11/11 i18n: bundle: mark strings for translationNguyễn Thái Ngọc Duy, Apr 16, 2012
  20. Jonathan NiederApr 18, 2012
  21. Nguyen Thai Ngoc DuyApr 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.