Opened 3 years ago

Closed 3 years ago

#32581 closed Cleanup/optimization (fixed)

to_locale should be idempotent

Reported by: Claude Paroz Owned by: Claude Paroz
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

In summary:

>>> from django.utils.translation import to_locale
>>> to_locale('en-us')
'en_US'  # <- Fine
>>> to_locale(to_locale('en-us'))
'en_us'  # <- Bad

Typically, this breaks using e.g. django.utils.translation.override with a locale code like pt_BR or zh_Hans. of course, we could document that override takes a language code, not a locale code, but if we can support both without much effort, this would be a lot better.

Change History (4)

comment:1 by Claude Paroz, 3 years ago

Has patch: set

comment:2 by Mariusz Felisiak, 3 years ago

Owner: changed from nobody to Claude Paroz
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:3 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In d11b9ffc:

Fixed #32581 -- Prevented to_locale() from corrupting locale names.

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