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.

wowas's avatar
1
wowas
asked 2013-05-17 07:29:21 -0500
Evgeny's avatar
13.2k
Evgeny
updated 2013-05-20 00:41:48 -0500
edit flag offensive 0 remove flag close merge delete

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.

Evgeny's avatar Evgeny (2013-05-17 16:44:09 -0500) edit

I check pluralization formula - it is OK. Other translation work OK. Problem only in this point (file utils.js).

wowas's avatar wowas (2013-05-19 02:49:55 -0500) edit

If the formula is ok and the translations are ok, then maybe the counter is wrong? Maybe you could try on django shell manually?

Evgeny's avatar Evgeny (2013-05-19 10:32:50 -0500) edit

Because in js code hours is float then we return float value that then round. If I change code like above then all OK.

wowas's avatar wowas (2013-05-19 23:55:38 -0500) edit

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.

Evgeny's avatar Evgeny (2013-05-20 00:01:31 -0500) edit
add a comment see more comments