Re: [PATCH 2/5] i18n: mark relative dates for translation
From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:53:19
On Fri, Mar 16, 2012 at 1:51 AM, Jonathan Nieder [off-list ref] wrote:
Hi, Nguyễn Thái Ngọc Duy wrote:quoted
English dates get correct plural/singular form as a side effect.[...]quoted
+++ b/date.c@@ -93,38 +93,46 @@ const char *show_date_relative(unsigned long time, int tz,[...]quoted
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 thatquoted
+ 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