Pārlūkot izejas kodu

Replace usages of capitalize() with capfirst()

* settings: moved the new call of capfirst() to the template
* coreutils: just replaced the calls due to simplicity

Fixes #9219
Stefan Hammer 2 gadi atpakaļ
vecāks
revīzija
baa278434c

+ 1 - 0
CHANGELOG.txt

@@ -32,6 +32,7 @@ Changelog
  * Fix: Support `formfield_callback` handling on `ModelForm.Meta` for future Django 4.2 release (Matt Westcott)
  * Fix: Ensure that `ModelAdmin` correctly supports filters in combination with subsequent searches without clearing the applied filters (Stefan Hammer)
  * Fix: Add missing translated values to site settings' headers and models presented in listings (Stefan Hammer)
+ * Fix: Remove `capitalize()` calls to avoid issues with other languages or incorrectly presented model names for reporting and parts of site settings (Stefan hammer)
 
 
 4.0.2 (xx.xx.xxxx) - IN DEVELOPMENT

+ 1 - 0
docs/releases/4.1.md

@@ -44,6 +44,7 @@ Wagtail 4.1 is designated a Long Term Support (LTS) release. Long Term Support r
  * Support `formfield_callback` handling on `ModelForm.Meta` for future Django 4.2 release (Matt Westcott)
  * Ensure that `ModelAdmin` correctly supports filters in combination with subsequent searches without clearing the applied filters (Stefan Hammer)
  * Add missing translated values to site settings' headers and models presented in listings (Stefan Hammer)
+ * Remove `capitalize()` calls to avoid issues with other languages or incorrectly presented model names for reporting and parts of site settings (Stefan hammer)
 
 ## Upgrade considerations
 

+ 2 - 2
wagtail/contrib/settings/models.py

@@ -146,7 +146,7 @@ class BaseSiteSetting(AbstractSetting):
 
     def __str__(self):
         return _("%(site_setting)s for %(site)s") % {
-            "site_setting": self._meta.verbose_name.capitalize(),
+            "site_setting": self._meta.verbose_name,
             "site": self.site,
         }
 
@@ -203,7 +203,7 @@ class BaseGenericSetting(AbstractSetting):
         return obj
 
     def __str__(self):
-        return self._meta.verbose_name.capitalize()
+        return self._meta.verbose_name
 
 
 class BaseSetting(BaseSiteSetting):

+ 1 - 1
wagtail/contrib/settings/templates/wagtailsettings/edit.html

@@ -1,7 +1,7 @@
 {% extends "wagtailadmin/base.html" %}
 {% load i18n wagtailadmin_tags %}
 
-{% block titletag %}{% blocktrans trimmed %}Editing {{ instance }}{% endblocktrans %}{% endblock %}
+{% block titletag %}{% blocktrans trimmed with instance=instance|capfirst %}Editing {{ instance }}{% endblocktrans %}{% endblock %}
 {% block bodyclass %}menu-settings{% endblock %}
 
 {% block content %}

+ 3 - 3
wagtail/coreutils.py

@@ -16,7 +16,7 @@ from django.db.models.base import ModelBase
 from django.dispatch import receiver
 from django.http import HttpRequest
 from django.utils.encoding import force_str
-from django.utils.text import slugify
+from django.utils.text import capfirst, slugify
 from django.utils.translation import check_for_language, get_supported_language_variant
 
 if TYPE_CHECKING:
@@ -157,10 +157,10 @@ def get_content_type_label(content_type):
     """
     model = content_type.model_class()
     if model:
-        return model._meta.verbose_name.capitalize()
+        return str(capfirst(model._meta.verbose_name))
     else:
         # no corresponding model class found; fall back on the name field of the ContentType
-        return content_type.model.capitalize()
+        return capfirst(content_type.model)
 
 
 def accepts_kwarg(func, kwarg):