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:2 by Berker Peksag, 10 years ago

Triage Stage: UnreviewedAccepted
Version: 1.7master

comment:3 by Berker Peksag, 10 years ago

Type: UncategorizedNew feature

comment:4 by Claude Paroz, 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:

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 Michal Čihař, 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 Tim Graham, 9 years ago

Patch needs improvement: unset

Claude, could you check the pull request now?

comment:7 by Claude Paroz, 9 years ago

Triage Stage: AcceptedReady for checkin

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

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