From: Nguyen Thai Ngoc Duy Date: Fri, 16 Mar 2012 11:47:06 GMT Subject: Re: [PATCH 2/5] i18n: mark relative dates for translation Message-ID: In-Reply-To: <20120315185102.GA4636@burratino> On Fri, Mar 16, 2012 at 1:51 AM, Jonathan Nieder wrote: > 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 " 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. > My other worry is that > >> +     struct strbuf sb = STRBUF_INIT; >> +     strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years); >> +     /* TRANSLATORS: "%s" is " 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 " ago", or "%d blah ago, ". 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