Skip to content

mvc: translate grid view labels - #10537

Closed
Opnwall wants to merge 1 commit into
opnsense:masterfrom
Opnwall:agent/translate-grid-view-labels
Closed

mvc: translate grid view labels#10537
Opnwall wants to merge 1 commit into
opnsense:masterfrom
Opnwall:agent/translate-grid-view-labels

Conversation

@Opnwall

@Opnwall Opnwall commented Jul 16, 2026

Copy link
Copy Markdown

Summary

  • translate labels declared inside grid_view
  • preserve the existing handling for all other grid view properties

Root cause

getFormGrid() translates a field's regular label, but a grid_view/label is copied into the grid record afterwards without passing through gettext(). This overwrites the translated field label with its untranslated grid-specific label.

For example, the Source NAT grid uses grid-specific labels such as Source, Port, and Destination, so those column headers remain in English even when the active locale contains translations for them.

Impact

Grid-specific column labels now use the active locale consistently with regular field labels.

Validation

  • php -l src/opnsense/mvc/app/controllers/OPNsense/Base/ControllerBase.php
  • git diff --check
  • verified on OPNsense 26.7 with the Chinese locale; the Source NAT headers render as translated values

} elseif ($key == 'sequence') {
$this_sequence = (string)$item;
} elseif ($key == 'label') {
$record[$key] = gettext((string)$item);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$record[$key] = gettext((string)$item);
if (strlen($text)) {
$record[$key] = gettext((string)$item);
}

good catch, these should be translated indeed, best also check for strsize for consistency with the dialog.

@Opnwall
Opnwall marked this pull request as ready for review July 16, 2026 07:45
@AdSchellevis AdSchellevis self-assigned this Aug 5, 2026
@AdSchellevis AdSchellevis added the cleanup Low impact changes label Aug 5, 2026
@AdSchellevis

Copy link
Copy Markdown
Member

merged in 21ccf46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Low impact changes

Development

Successfully merging this pull request may close these issues.

2 participants