#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)
follow-up: 2 comment:1 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 7 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 theLanguage*fields :-(
...and rename the newly created es directory to ht.
comment:3 by , 7 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?
EDIT: I just reread that and you're saying to temporarily make it "es" and then switch the settings back. :-(
comment:4 by , 7 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 , 7 years ago
And what about providing a Haitian translation for Django itself?
https://docs.djangoproject.com/en/2.0/internals/contributing/localizing/
Hi Ed,
When you run makemessages for the first time (i.e. a
django.pofile is going to be created for you), these plural form PO files header fields are copied by Django from its own .po files (found indjango/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
httranslation for Django itself so there is nodjango/conf/locale/ht/LC_MESSAGES/*.poand 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 theLanguage*fields :-(