Kaynağa Gözat

Fixes #23753: Translate journal entry created_by column header (#23764)

Mark the column header for lazy translation so it respects the active
language. Add a regression test to verify the translated header.
lexapi 14 saat önce
ebeveyn
işleme
69679e6f8d

+ 3 - 0
netbox/extras/tables/tables.py

@@ -778,6 +778,9 @@ class JournalEntryTable(NetBoxTable):
         timespec='minutes',
         linkify=True
     )
+    created_by = tables.Column(
+        verbose_name=_('Created by')
+    )
     assigned_object_type = columns.ContentTypeColumn(
         verbose_name=_('Object Type')
     )

+ 10 - 2
netbox/extras/tests/test_tables.py

@@ -1,10 +1,12 @@
-from django.test import TestCase
+from django.test import TestCase, tag
+from django.utils import translation
+from django.utils.translation import gettext
 
 from core.events import OBJECT_CREATED
 from core.models import ObjectType
 from dcim.models import Site
 from extras.choices import CustomFieldStatusChoices, CustomFieldTypeChoices
-from extras.models import Bookmark, CustomField, EventRule, Notification, Subscription
+from extras.models import Bookmark, CustomField, EventRule, JournalEntry, Notification, Subscription
 from extras.tables import *
 from utilities.testing import TableTestCases
 
@@ -190,3 +192,9 @@ class ImageAttachmentTableTestCase(TableTestCases.StandardTableTestCase):
 
 class JournalEntryTableTestCase(TableTestCases.StandardTableTestCase):
     table = JournalEntryTable
+
+    @tag('regression')  # Ref: #23753
+    def test_created_by_header_translated(self):
+        with translation.override('nl'):
+            table = JournalEntryTable(JournalEntry.objects.none())
+            self.assertEqual(table.columns['created_by'].header, gettext('Created by'))