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

Re: [PATCH 2/5] i18n: mark relative dates for translation

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Mar 16, 2012, 11:47 UTC
Message-ID
<CACsJy8D0KN_M3txmq3J==3Q5=u2XAa0hR=Wm+=T3qYN+LAuWkQ@mail.gmail.com>
In-Reply-To
<20120315185102.GA4636@burratino>
On Fri, Mar 16, 2012 at 1:51 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 20 quoted lines
> Hi,
>
> Nguyễn Thái Ngọc Duy wrote:
>
>> English dates get correct plural/singular form as a side effect.
> [...]
>> +++ b/date.c
>> @@ -93,38 +93,46 @@ const char *show_date_relative(unsigned long time, int tz,
> [...]
>>       if (diff < 90) {
>> -             snprintf(timebuf, timebuf_size, "%lu seconds ago", diff);
>> +             snprintf(timebuf, timebuf_size,
>> +                      Q_("%lu second ago", "%lu seconds ago", diff), diff);
>>               return timebuf;
>
> This leaves me vaguely nervous --- sure, no language is going to use
> an expression for "<n> years" that is more than 200 bytes long, but if
> one does, it would get truncated.
>
> Would something like the following (untested) on top make sense?
It does. I will reuse your patch next time.
Show 12 quoted lines
> My other worry is that
>
>> +     struct strbuf sb = STRBUF_INIT;
>> +     strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years);
>> +     /* TRANSLATORS: "%s" is "<n> years" */
>> +     snprintf(timebuf, timebuf_size,
>> +              Q_("%s, %lu month ago", "%s, %lu months ago", months),
>> +              sb.buf, months);
>> +     strbuf_release(&sb);
>
> seems excessively complicated.  How do translations normally deal with
> cases like this of strings with multiple numbers in them?

I don't recall any similar cases. A search for 'ago"' in all gnome translations I have only shows "<one number> ago", or "%d blah ago, <absolute time>". The closet is probably strftime, where translators are free to reorder date and time items, something like this

/* Translators: the first %s is the number of months, the second the number of years */ sprintf(.., "%s, %s ago", month_string, year_string);

Or we can just round it up and show only one number.
-- 
Duy
Previous: Jonathan NiederNext: Nguyễn Thái Ngọc Duy
Message 11 of 15 in “i18n-ize relative dates, git-help and parseopt”
  1. 0/5 i18n-ize relative dates, git-help and parseoptNguyễn Thái Ngọc Duy, Mar 8, 2012
  2. 1/5 i18n: keep the last \n even when text is poisonedNguyễn Thái Ngọc Duy, Mar 8, 2012
  3. Jonathan NiederMar 8, 2012
  4. Nguyen Thai Ngoc DuyMar 9, 2012
  5. Nguyen Thai Ngoc DuyMar 9, 2012
  6. Ævar Arnfjörð BjarmasonMar 9, 2012
  7. 2/5 i18n: mark relative dates for translationNguyễn Thái Ngọc Duy, Mar 8, 2012
  8. Jonathan NiederMar 15, 2012
  9. Johannes SixtMar 15, 2012
  10. Jonathan NiederMar 15, 2012
  11. Nguyen Thai Ngoc DuyMar 16, 2012
  12. 3/5 i18n: parseopt: lookup help and argument translations when showing usageNguyễn Thái Ngọc Duy, Mar 8, 2012
  13. Jonathan NiederMar 8, 2012
  14. 4/5 i18n: help: mark parseopt strings for translationNguyễn Thái Ngọc Duy, Mar 8, 2012
  15. 5/5 i18n: help: mark strings for translationNguyễn Thái Ngọc Duy, Mar 8, 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.