Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29587 closed Bug (invalid)

Problem with "Plural-forms" generated in PO file for Haitian Language

Reported by: Ed Menendez Owned by: nobody
Component: Uncategorized Version: 1.11
Severity: Normal Keywords: i18n, haitian
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you makemessages for locale=ht (Haitian language), it generates a plural-form like this:

"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

It should instead look like this:

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

The workaround is to manually edit the PO file after generation. If you try to use the incorrect PO file it will generate this error:

ValueError: "invalid token in plural form": EXPRESSION

Change History (5)

comment:1 by Ramiro Morales, 6 years ago

Resolution: invalid
Status: newclosed

Hi Ed,

When you run makemessages for the first time (i.e. a django.po file is going to be created for you), these plural form PO files header fields are copied by Django from its own .po files (found in django/conf/locale/<LOCALE NAME>/LC_MESSAGES/*.po)

There is no locally available database of plural forms formulas, nor a fancy scheme to e.g. get it from a repository.

This means Django unfortunately has no way to insert the right header there because there is no ht translation for Django itself so there is no django/conf/locale/ht/LC_MESSAGES/*.po and so the generic "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" value as written by the GNU gettext CLI tools is left intact.

One workaround could be to use another locale with the same plural forms formula, like es, but then you'll have to edit the Language* fields :-(

in reply to:  1 comment:2 by Ramiro Morales, 6 years ago

Replying to Ramiro Morales:

One workaround could be to use another locale with the same plural forms formula, like es, but then you'll have to edit the Language* fields :-(

...and rename the newly created es directory to ht.

comment:3 by Ed Menendez, 6 years ago

The workaround causes a few undesired side effects. Assuming I'm not using "es" and I make "ht" use the "es" language code.. then the page will read <html lang="es"> for Haitian which will cause other problems.

Manually editing the PO file seems like a better workaround.

For the future though, should there be a way to provide the default header to Django for languages that aren't officially Django supported? Maybe include a /templates/locale/defaults/ht/ or something like that. Or possibly provide the needed values in a dictionary in settings.py?

Version 0, edited 6 years ago by Ed Menendez (next)

comment:4 by Ed Menendez, 6 years ago

Another solution would be for Django provide instructions when you run "makemessages" so that it warns about the situation and what the workarounds are.

comment:5 by Claude Paroz, 6 years ago

And what about providing a Haitian translation for Django itself?
https://docs.djangoproject.com/en/2.0/internals/contributing/localizing/

Note: See TracTickets for help on using tickets.
Back to Top