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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
wowas's avatar
1
wowas
asked 11 years ago
Evgeny's avatar
13.2k
Evgeny
updated 11 years ago

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 (11 years ago)

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

wowas's avatar wowas (11 years ago)

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 (11 years ago)

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 (11 years ago)

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 (11 years ago)
see more comments