On Fri, Mar 16, 2012 at 1:51 AM, Jonathan Nieder <jrnieder@xxxxxxxxx> 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 "<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. > 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html