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

Re: [PATCH] i18n: Not add stripped contents for translation

From
Jens Lehmann <jens.lehmann@web.de>
Date
Mar 5, 2012, 19:34 UTC
Message-ID
<4F55155A.3050309@web.de>
In-Reply-To
<7vobsb67dn.fsf@alter.siamese.dyndns.org>
Am 05.03.2012 04:42, schrieb Junio C Hamano:
Show 49 quoted lines
> 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".

I have no objections at all against changing the code that way to make it possible to translate it in a sane way. This code predates the i18n effort by a few months, so it didn't take this kind of problem into account.

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 10 in “i18n: Not add stripped contents for translation”
  1. i18n: Not add stripped contents for translationJiang Xin, Mar 5, 2012
  2. Junio C HamanoMar 5, 2012
  3. Jiang XinMar 5, 2012
  4. Junio C HamanoMar 5, 2012
  5. Jens LehmannMar 5, 2012
  6. Junio C HamanoMar 5, 2012
  7. Jiang XinMar 6, 2012
  8. Junio C HamanoMar 6, 2012
  9. Jiang XinMar 6, 2012
  10. Jiang XinMar 6, 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.