git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jiang Xin <worldhello.net@gmail.com>
Cc: "Git List" <git@vger.kernel.org>,
	"Ævar Arnfjörð" <avarab@gmail.com>,
	"Jens Lehmann" <Jens.Lehmann@web.de>
Subject: Re: [PATCH] i18n: Not add stripped contents for translation
Date: Sun, 04 Mar 2012 19:42:28 -0800	[thread overview]
Message-ID: <7vobsb67dn.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CANYiYbGdJ0yFmPnsK_JdABwmFraVdNi08QgFKRmGzJt-DA9tBw@mail.gmail.com> (Jiang Xin's message of "Mon, 5 Mar 2012 11:01:30 +0800")

Jiang Xin <worldhello.net@gmail.com> writes:

> Orignal source code:
>
> 244   case WT_STATUS_CHANGED:
> 245     if (d->new_submodule_commits || d->dirty_submodule) {
> 246       strbuf_addstr(&extra, " (");
> 247       if (d->new_submodule_commits)
> 248         strbuf_addf(&extra, _("new commits, "));
> 249       if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
> 250         strbuf_addf(&extra, _("modified content, "));
> 251       if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
> 252         strbuf_addf(&extra, _("untracked content, "));
> 253       strbuf_setlen(&extra, extra.len - 2);
> 254       strbuf_addch(&extra, ')');
> 255     }
>
> The bad thing is strbuf_setlen() at line 253. We can not asume the translation
> of ", " must be 2 characters.

It sounds like you are merely working around a poor style in the original,
which should have been structured more like this in the first place, no?

        /* a helper function elsewhere, possibly inlined */
        static void add_iwsep_as_needed(struct strbuf *buf, int origlen)
        {
                if (buf->len != origlen)
                        strbuf_addstr(buf, _(","));
        }

        ...
        int origlen;

        strbuf_addstr(&extra, " ("))
        origlen = extra.len;
        if (a)
                strbuf_addstr(&extra, _("msg a"));
        if (b) {
                add_iwsep_as_needed(&extra, origlen);
                strbuf_addstr(&extra, _("msg b"));
        }
        if (c) {
                add_iwsep_as_needed(&extra, origlen);
                strbuf_addstr(&extra, _("msg c"));
        }
        strbuf_addstr(&extra, ")");

Cc'ing Jens whose 9297f77 (git status: Show detailed dirty status of
submodules in long format, 2010-03-08) introduced the "two-byte backstep".


This is a tangent and I am just showing aloud my ignorance, but I wonder
if there is a reasonably generic and "best current practice" way to
structure code to show an enumeration in human languages, for example,

	A, B, C and D.

in an easier-to-translate way.

I suspect that it might be sufficiently generic if we can make it possible
to allow the first and the last inter-word-separation and the token after
all the items to be different from other inter-word-separation tokens.

E.g. in English, the first one and all the "other" are ", ", the last
inter-word token is " and ", and the token at the very end is ".". In
Japanese some translators may want to say "AやBとCとD。", meaning the
first one is "や", "。" is used at the very end, and all the others may be
"と".

  reply	other threads:[~2012-03-05  3:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05  1:21 [PATCH] i18n: Not add stripped contents for translation Jiang Xin
2012-03-05  2:27 ` Junio C Hamano
2012-03-05  3:01   ` Jiang Xin
2012-03-05  3:42     ` Junio C Hamano [this message]
2012-03-05 19:34       ` Jens Lehmann
2012-03-05 20:08         ` Junio C Hamano
2012-03-06  4:16       ` Jiang Xin
2012-03-06  6:46         ` Junio C Hamano
2012-03-06  6:55           ` Jiang Xin
2012-03-06  6:47         ` Jiang Xin

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=7vobsb67dn.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=worldhello.net@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).