From: Jonathan Nieder <jrnieder@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] transport.c: mark push status strings for translation
Date: Wed, 13 Nov 2013 15:25:29 -0800 [thread overview]
Message-ID: <20131113232529.GQ10302@google.com> (raw)
In-Reply-To: <1384345833-8345-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
> Strings are only marked for translations, the actual lookup is delayed
> until inside print_ref_status(), so we only have to check for
> porcelain flag once.
I was confused about what this means (why would it be faster to call
gettext() once inside print_ref_status() instead of once per caller
in the argument to print_ref_status()?) until I looked at the code.
I guess you mean something like
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.
> While at there, mark some error strings in git push for translation
> too.
Thanks.
[...]
> +++ b/transport.c
[...]
> @@ -627,16 +628,17 @@ 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);
> + /* compensate the invisible bytes in utf-8 strings */
> + width += strlen(localized_summary) - utf8_strwidth(localized_summary);
> + fprintf(stderr, " %c %-*s ", flag, width, localized_summary);
Nit: "Compensate for the ...".
What would happen if 'width' became negative? That can't happen
because none of the doublewidth characters are ASCII characters, so
the question is just academic, but maybe it's worth a note in the
comment to avoid slowing down people reading.
> if (from)
> fprintf(stderr, "%s -> %s", prettify_refname(from->name), prettify_refname(to->name));
I'm not sure this is correct for right-to-left languages. Something
to solve another day.
The rest looks good.
If the commit message is clarified,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
next prev parent reply other threads:[~2013-11-13 23:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 12:30 [PATCH] transport.c: mark push status strings for translation Nguyễn Thái Ngọc Duy
2013-11-13 23:25 ` Jonathan Nieder [this message]
2013-11-16 3:21 ` Duy Nguyen
2013-11-16 3:19 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131113232529.GQ10302@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).