Skip to content

Commit

Permalink
Add verbose name to locale field of TranslatableMixin (wagtail#12071)
Browse files Browse the repository at this point in the history
  • Loading branch information
garraflavatra authored and gasman committed Jun 24, 2024
1 parent ead391e commit ad95e0a
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Changelog
* Fix: Allow renditions of `.ico` images (Julie Rymer)
* Fix: Handle choice groups as dictionaries in active filters (Sébastien Corbin)
* Fix: Add separators when displaying multiple error messages on a StructBlock (Kyle Bayliss)
* Fix: Specify `verbose_name` on `TranslatableMixin.locale` so that it is translated when used as a label (Romein van Buren)
* Docs: Remove duplicate section on frontend caching proxies from performance page (Jake Howard)
* Docs: Document `restriction_type` field on PageViewRestriction (Shlomo Markowitz)
* Docs: Document Wagtail's bug bounty policy (Jake Howard)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@
* Roel Koper
* Inju Michorius
* Jeroen de Vries
* Romein van Buren

## Translators

Expand Down
1 change: 1 addition & 0 deletions docs/releases/6.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ depth: 1
* Allow renditions of `.ico` images (Julie Rymer)
* Fix the rendering of grouped choices when using ChoiceFilter in combination with choices (Sébastien Corbin)
* Add separators when displaying multiple error messages on a StructBlock (Kyle Bayliss)
* Specify `verbose_name` on `TranslatableMixin.locale` so that it is translated when used as a label (Romein van Buren)


### Documentation
Expand Down
19 changes: 19 additions & 0 deletions wagtail/migrations/0094_alter_page_locale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.6 on 2024-06-21 06:47

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0093_uploadedfile'),
]

operations = [
migrations.AlterField(
model_name='page',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
]
7 changes: 6 additions & 1 deletion wagtail/models/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.dispatch import receiver
from django.utils import translation
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey

from wagtail.actions.copy_for_translation import CopyForTranslationAction
Expand Down Expand Up @@ -177,7 +178,11 @@ def is_active(self) -> bool:
class TranslatableMixin(models.Model):
translation_key = models.UUIDField(default=uuid.uuid4, editable=False)
locale = models.ForeignKey(
Locale, on_delete=models.PROTECT, related_name="+", editable=False
Locale,
on_delete=models.PROTECT,
related_name="+",
editable=False,
verbose_name=_("locale"),
)
locale.wagtail_reference_index_ignore = True

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 5.0.6 on 2024-06-21 06:47

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('i18n', '0002_clusterabletestmodel_clusterabletestmodelchild_clusterabletestmodeltranslatablechild'),
('wagtailcore', '0094_alter_page_locale'),
]

operations = [
migrations.AlterField(
model_name='clusterabletestmodel',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='clusterabletestmodeltranslatablechild',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='testchildobject',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='testmodel',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='testnonparentalchildobject',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2024-06-21 06:47

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('snippetstests', '0011_nonautocompletesearchablesnippet'),
('wagtailcore', '0094_alter_page_locale'),
]

operations = [
migrations.AlterField(
model_name='translatablesnippet',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 5.0.6 on 2024-06-21 06:47

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tests', '0038_sociallink'),
('wagtailcore', '0094_alter_page_locale'),
]

operations = [
migrations.AlterField(
model_name='eventcategory',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='eventpagecarouselitem',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='eventpagerelatedlink',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='eventpagespeaker',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='eventpagespeakeraward',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
migrations.AlterField(
model_name='fullfeaturedsnippet',
name='locale',
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale', verbose_name='locale'),
),
]

0 comments on commit ad95e0a

Please sign in to comment.