Opened 10 years ago
Closed 9 years ago
#24063 closed New feature (fixed)
Locale code validation too strict
Reported by: | Michal Čihař | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The locale code validation is too strict as it refuses locale variants which are used by some. See https://www.gnu.org/software/gettext/manual/html_node/Locale-Names.html for more information. Most frequently it can be seen with languages which can be written in both Latin and Cyrillic.
I will provide pull request for this.
Change History (8)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | 1.7 → master |
comment:3 by , 10 years ago
Type: | Uncategorized → New feature |
---|
comment:4 by , 10 years ago
Patch needs improvement: | set |
---|
I think this issue is a little more complicated. There are several families of language codes. But basically, we are handling two different ones in Django:
- IETF Language tags coming from the browser, defined in http://tools.ietf.org/html/rfc5646
- POSIX locale codes (http://en.wikipedia.org/wiki/Locale) which is the format used by gettext translations file names.
We should not mix those. See also django.utils.translation.trans_real.to_locale/to_language
which is the code trying to map strings from one code to the other. To correctly handle script variants, there is surely some more clever mapping work to do (e.g. Cyrl
in RFC5646 should map to @cyrillic
in the POSIX locale).
comment:5 by , 10 years ago
Indeed handling Language tags coming from the browser is not covered by my patch. What I've tried to address is to allow Django to set such locale manually. Automatic mapping of browser locales would be indeed nice.
comment:6 by , 9 years ago
Patch needs improvement: | unset |
---|
Claude, could you check the pull request now?
comment:7 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Pull requests for master and 1.7.x:
https://github.com/django/django/pull/3815
https://github.com/django/django/pull/3816