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