Opened 9 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


The locale code validation is too strict as it refuses locale variants which are used by some. See 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:2 Changed 9 years ago by Berker Peksag

Triage Stage: UnreviewedAccepted
Version: 1.7master

comment:3 Changed 9 years ago by Berker Peksag

Type: UncategorizedNew feature

comment:4 Changed 9 years ago by Claude Paroz

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:

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 Changed 9 years ago by Michal Čihař

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 Changed 9 years ago by Tim Graham

Patch needs improvement: unset

Claude, could you check the pull request now?

comment:7 Changed 9 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin

comment:8 Changed 9 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 76d26d89:

Fixed #24063 -- Allowed locale variants supported by gettext.

The locale code can contain a variant after @, so allowed that.

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