Remove capitalize() calls to avoid issues with other languages
See original GitHub issueIs your proposal related to a problem?
There are (only) 4 calls of capitalize()
in wagtail’s codebase and 3 of them actually lead to a bad wording in german, for example.
1) get_content_type_label()
:
https://github.com/wagtail/wagtail/blob/bf3a054c04eb66a923bac538caa64165fef79131/wagtail/coreutils.py#L153-L163
I think the second call (fallback if no model exists) can be kept, but the first one, which uses verbose_name
, should be removed.
This is used in the audit logs for example:
“Live-Update” (stored in verbose_name
) is transformed to “Live-update”, which looks like a mistake in german.
2) Site settings: https://github.com/wagtail/wagtail/blob/bf3a054c04eb66a923bac538caa64165fef79131/wagtail/contrib/settings/models.py#L146-L147 https://github.com/wagtail/wagtail/blob/bf3a054c04eb66a923bac538caa64165fef79131/wagtail/contrib/settings/models.py#L201-L202
This results in the following: This example also shows some other translation issues, which I’ve fixed in #9217 (and in transifex).
Describe the solution you’d like
Can we remove the capitalize()
calls where verbose_name
is used, so it it can be properly translated?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
@th3hamm0r - as per your question - let’s go with the adoption of the
capfirst
in your PR - makes sense, if in the template - great, if not that is fine also.After more digging, I can see that we use
capfirst
in the Python code a lot also, even throughout the settings app, for essentially the same purpose.I never realised that
capitalize
lower-cases capital letters (other than the initial one) that were capitalised in the input! That seems counter-productive in any language.Looks like Django’s
django.utils.text.capfirst
does what we want: https://github.com/django/django/blob/9c42933711667034c9335f408e1a8a53031e9865/django/utils/text.py#L14-L21