Translate "hours ago" in utils.js
When translate string from utils.js then appear bugs. See row 3074:
return interpolate(
ngettext(
'%s hour ago',
'%s hours ago',
hours
),
[Math.floor(hours),]
)
If translate to Russian and add three variants:
msgid "%s hour ago"
msgid_plural "%s hours ago"
msgstr[0] "%s час назад"
msgstr[1] "%s часа назад"
msgstr[2] "%s часов назад"
We get:
1 часа назад
(must be 1 час назад
)
4 часов назад
(must be 4 часа назад
)
Cause by shifting from floor
.
Code must be:
return interpolate(
ngettext(
'%s hour ago',
'%s hours ago',
Math.floor(hours)
),
[Math.floor(hours),]
)
The same for minutes. Please update.
Comments
There is incorrect pluralization formula in django.po and djangojs.po. I am looking into how to fix this while retaining the Transifex service.
I check pluralization formula - it is OK. Other translation work OK. Problem only in this point (file utils.js).
If the formula is ok and the translations are ok, then maybe the counter is wrong? Maybe you could try on django shell manually?
Because in js code
hours
is float then we return float value that then round. If I change code like above then all OK.Ah, great - does it work correctly with hours < 1? Hmm, actually I don't see this in the code. In the github version we already have the
.floor()
part and it's on a different line number.