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

Re: [PATCH/RESEND] transport.c: mark push status strings for translation

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 3, 2013, 20:08 UTC
Message-ID
<20131203200857.GE29959@google.com>
In-Reply-To
<1386066409-15262-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
> Mark strings like "[up to date]" passed to print_ref_status() for
> translation with N_() instead of _() so they can remain untranslated
> in porcelain mode.
Makes sense.
[...]
> --- a/builtin/push.c
> +++ b/builtin/push.c

Perhaps it would make sense to send these as a separate patch, since they are simpler than the rest.

[...]
Show 17 quoted lines
> --- a/transport.c
> +++ b/transport.c
> @@ -14,6 +14,7 @@
>  #include "url.h"
>  #include "submodule.h"
>  #include "string-list.h"
> +#include "utf8.h"
>  
>  /* rsync support */
>  
> @@ -627,16 +628,23 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
>  		else
>  			fprintf(stdout, "%s\n", summary);
>  	} else {
> -		fprintf(stderr, " %c %-*s ", flag, TRANSPORT_SUMMARY_WIDTH, summary);
> +		int width = TRANSPORT_SUMMARY_WIDTH;
> +		const char *localized_summary = _(summary);
The summary arg comes from one of a few places:
 (a) [deleted] etc from print_ok_ref_status, which you marked
     with N_ (good)
 (b) deadbe... from status_abbrev via print_ok_ref_status.  Can we
     avoid passing it to gettext()?
 (c) [no match] etc from print_one_push_status, marked with
     N_ (good)
I am tempted to suggest something like
		const char *localized_summary;
		if (*summary != '[')
			/* Leave abbreviated sha1 from status_abbrev() alone */
			localized_summary = summary;
		else
			localized_summary = _(summary);

but that's kind of ugly. Is there a simpler way? Should the summary arg be passed in already localized (with 'porcelain' handling higher up)?

Thanks, Jonathan

Previous: Nguyễn Thái Ngọc Duy
Message 2 of 2 in “transport.c: mark push status strings for translation”
  1. transport.c: mark push status strings for translationNguyễn Thái Ngọc Duy, Dec 3, 2013
  2. Jonathan NiederDec 3, 2013

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.