[Django] #29693: Django admin corrupted first character in verbose_name for languages without capital letters

22 views
Skip to first unread message

Django

unread,
Aug 20, 2018, 1:27:30 PM8/20/18
to django-...@googlegroups.com
#29693: Django admin corrupted first character in verbose_name for languages
without capital letters
-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: | Status: new
Uncategorized |
Component: | Version: 2.1
contrib.admin | Keywords: translation
Severity: Normal | localization corrupted character
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When using **Django admin** for **ka-ge** language first characters gets
corrupted, because language dose not have capital letters.
For example "username" in Georgian is "მომხმარებლის სახელი" and when first
letter is capitalized it's displayed as "Სომხმარებლის სახელი".

You can test this case when "**log in**" page is displayed for admin.

In **django.contrib.admin.forms.AuthenticationForm**

{{{
def __init__(self, request=None, *args, **kwargs):
self.request = request
self.user_cache = None
super().__init__(*args, **kwargs)
self.username_field =
UserModel._meta.get_field(UserModel.USERNAME_FIELD)
self.fields['username'].max_length =
self.username_field.max_length or 254
if self.fields['username'].label is None:
# This is the line when character gets corrupted
self.fields['username'].label =
capfirst(self.username_field.verbose_name)
}}}

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

Django

unread,
Aug 20, 2018, 1:29:28 PM8/20/18
to django-...@googlegroups.com
#29693: Django admin corrupted first character in verbose_name for languages
without capital letters
-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage:
localization corrupted character | Unreviewed
Has patch: 0 | Needs documentation: 0

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

* Attachment "log_in_page.png" added.

screen of the page

Django

unread,
Aug 20, 2018, 3:55:09 PM8/20/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

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

* type: Uncategorized => Bug
* component: contrib.admin => Utilities
* stage: Unreviewed => Accepted


Comment:

Any idea how `django.utils.text.capfirst()` could be adapted to fix the
issue? I was thinking maybe we could check `ord()` of the first
character's `upper()` but I'm not sure if that's reliable.or not.

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

Django

unread,
Aug 21, 2018, 2:38:46 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I cannot reproduce this issue on a Linux/Python3.5 system.

{{{
>>> ord('მ')
4315
>>> ord('მ'.upper())
4315
}}}

What system are you using?

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

Django

unread,
Aug 21, 2018, 4:00:05 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by irakli khitarishvili):

Python : 3.7.0
System : Windows 7, Linux (Ubuntu 17.10)

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

Django

unread,
Aug 21, 2018, 4:46:03 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

That's weird. However, I don't think that's something that Django can
change. It must be related to the underlying Unicode library mappings.
Maybe other people can test to see if the issue you are seeing is the
exception or the rule!

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

Django

unread,
Aug 21, 2018, 5:07:18 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

Repeating Claude's test on macOS with Python 3.6 and 3.7 and on Windows 10
(with both `cmd` and WSL bash) I get the same result:

{{{
>>> ord('მ')
4315
>>> ord('მ'.upper())
4315
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29693#comment:5>

Django

unread,
Aug 21, 2018, 9:07:38 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: new
Component: Utilities | Version: 2.1
Severity: Normal | Resolution:
Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Looks like Python 3.7 is required to reproduce. Bisected to
https://github.com/python/cpython/commit/4705ea38c900f068fd262aca02943896d1123544.

On Ubuntu 18.04 with a manually installed Python 3.7:
{{{
>>> ord('მ'.upper())
7323
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29693#comment:6>

Django

unread,
Aug 21, 2018, 11:34:26 AM8/21/18
to django-...@googlegroups.com
#29693: capfirst() corrupts text for languages without capital letters

-------------------------------------+-------------------------------------
Reporter: irakli | Owner: nobody
khitarishvili |
Type: Bug | Status: closed
Component: Utilities | Version: 2.1
Severity: Normal | Resolution: invalid

Keywords: translation | Triage Stage: Accepted
localization corrupted character |
Has patch: 0 | Needs documentation: 0

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

* status: new => closed
* resolution: => invalid


Comment:

Maybe a Unicode bug, then? Looks like `&#7323;` / `\u1C9B` / https
://unicode-table.com/en/1C9B/ has no information in Unicode. (not that
Unicode does have capitals for Georgian, see e.g. https://unicode-
table.com/en/10AB/).

Anyway, I fear the resolution will not take place in Django, but in Python
or in Unicode data. I'd suggest trying to report the issue in Python.

--
Ticket URL: <https://code.djangoproject.com/ticket/29693#comment:7>

Reply all
Reply to author
Forward
0 new messages