[Django] #32581: to_locale should be idempotent

2 views
Skip to first unread message

Django

unread,
Mar 21, 2021, 1:53:20 PM3/21/21
to django-...@googlegroups.com
#32581: to_locale should be idempotent
------------------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Internationalization | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32581>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 21, 2021, 2:05:31 PM3/21/21
to django-...@googlegroups.com
#32581: to_locale should be idempotent
-------------------------------------+-------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/14164 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/32581#comment:1>

Django

unread,
Mar 22, 2021, 1:28:35 AM3/22/21
to django-...@googlegroups.com
#32581: to_locale should be idempotent
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned

Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Claude Paroz
* status: new => assigned
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/32581#comment:2>

Django

unread,
Mar 22, 2021, 2:10:02 AM3/22/21
to django-...@googlegroups.com
#32581: to_locale should be idempotent
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32581#comment:3>

Django

unread,
Mar 22, 2021, 3:18:15 AM3/22/21
to django-...@googlegroups.com
#32581: to_locale should be idempotent
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: closed
Component: | Version: dev
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"d11b9ffcc0b1d6b8e87df6319f09bf284196e41a" d11b9ffc]:
{{{
#!CommitTicketReference repository=""
revision="d11b9ffcc0b1d6b8e87df6319f09bf284196e41a"
Fixed #32581 -- Prevented to_locale() from corrupting locale names.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32581#comment:4>

Reply all
Reply to author
Forward
0 new messages