Incorrect time delta on post (Ru interface only)

Hi, we are on 1.9.4 stable. Possible found a bug in post time delta (don’t know how to say).

Look in the picture, please (sorry for non-English). The original post date is February 27th, but today (March 20th) it shows the post as written 1 day ago:

This post is shown correctly in the list of latest, but has the same 1-day-ago stamp:

Links:


We need a repro here. Could be a per-language issue as well, depending on the translations.

1 Like

Thank you, it should be 21 instead 1 :grinning:. Today the problem has gone away. Another posts become bad, the magic number is 21.

1 Like

We’ve had problems like this reported over the years. I suspect it’s something wrong with this pluralization logic, but I would expect it to have been reported by now:

MessageFormat.locale.ru = function (n) {
  var r10 = n % 10, r100 = n % 100;

  if (r10 == 1 && r100 != 11)
    return 'one';

  if (r10 >= 2 && r10 <= 4 && (r100 < 12 || r100 > 14) && n == Math.floor(n))
    return 'few';

  return 'other';
};

That logic is very strange to us English-speakers… :wink:

4 Likes

I have 101 problem understanding this.

2 Likes

That’s really funny moment :slight_smile:

Here is a case suitable for phrase “This topic has been written N days ago” (“Эта тема была написана N дней назад”). The word “days” in Russian depends on N:

‘few’ (дня) = 2,3,4, 22,23,24, 32,33,34…
‘other’ (дней) = 5-20, 25-30, 35-40…
‘one’ (день) = 1, 21, 31, 41…

I see that delta > 30 days is not used in UI, day+month is used instead. I tried to test modified code but without success.

5 Likes

This issue is caused by wrong translations. In Russian the “one” key isn’t only used for the value 1, but also for 21, 31, 41,… That’s why you should always use %{count} instead of the value “1” within translations, otherwise all those values will be truncated to 1. :wink:

So, you’ll need to update all pluralized strings and make sure that the “one” key contains the appropriate count variable instead of the value 1. You can use the “pluralized: yes” filter on Transifex to find all the affected strings.


As an aside, the plural rules used by Discourse aren’t 100% correct. According to the Unicode Plural Rules there should be “one”, “few”, “many” and “other”.

“many” was removed in 2014, because there was an issue with Transifex, which seems to be fixed since 2015. We never added it back and looking at the plural rules I think it doesn’t matter a lot, because I believe we aren’t displaying decimal numbers anywhere in the UI. But please be aware that Discourse is currently using “other” where it should be using “many”!

11 Likes