Django

Code

Ticket #6864 (closed: fixed)

Opened 9 months ago

Last modified 9 months ago

JavaScript i18n support can fail for languages with two plural forms

Reported by: ramiro Assigned to: nobody
Milestone: Component: Internationalization
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

If, as exemplified in the official GNU gettext documentation, the plural form specification headers

"Plural-Forms: nplurals=2; plural=n != 1;\n"

or

"Plural-Forms: nplurals=2; plural=n>1;\n"

are used instead of

"Plural-Forms: nplurals=2; plural=n != 1 ? 1 : 0;\n"

or

"Plural-Forms: nplurals=2; plural=n>1 ? 1 : 0;\n"

respectively in a (Django or application) djangojs.po catalog, the ngettext() function fails because the first ones, being C language expressions, rely on the C feature that boolean expressions have to value zero or one. In JavaScript, a boolean in the context of an array index doesn't evaluate to zero or one.

See http://groups.google.com/group/django-users/browse_frm/thread/12f39fe090d39e78?hl=en for the original report by Julien.

This could affect JS i18n for languages that use two-forms pluralization rules, i.e.: Danish, Dutch, English, Faroese, German, Norwegian, Swedish, Estonian, Finnish, Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto, French, Brazilian Portuguese (see the GNU gettext documentation linked above.)

The attached patch modifies the pluralidx() function to work on both scenarios.

Attachments

js-i18n-pluralf.diff (0.8 kB) - added by ramiro on 03/23/08 15:23:17.

Change History

03/23/08 15:23:17 changed by ramiro

  • attachment js-i18n-pluralf.diff added.

03/23/08 19:15:59 changed by ramiro

  • needs_better_patch changed.
  • component changed from Uncategorized to Internationalization.
  • needs_tests changed.
  • needs_docs changed.

03/24/08 01:21:19 changed by mtredinnick

  • stage changed from Unreviewed to Ready for checkin.

Thanks, Ramiro. Saved me from having to write this. I agree we need to handle both forms, because the boolean form will be copied from other, similar files.

03/24/08 08:27:19 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [7356]) Fixed #6864 -- Handle Javascript i18n when the plural form expression returns True or False (so both booleans and integers are allowed). Thanks, Ramiro Morales.


Add/Change #6864 (JavaScript i18n support can fail for languages with two plural forms)




Change Properties
Action