fix: apply translation to container tab name in getTabNameForItem#1214
Open
bsitfeng wants to merge 1 commit into
Open
fix: apply translation to container tab name in getTabNameForItem#1214bsitfeng wants to merge 1 commit into
bsitfeng wants to merge 1 commit into
Conversation
Container tab names were displayed using \$data['label'] directly without going through the translation system. This fix applies getLabelFor() to correctly display translated tab labels based on the user's language. Fixes tab name translation not working when language is set to non-default.
Contributor
|
Hi @bsitfeng can you adapt CHANGELOG.md ## [UNRELEASED]
### Fixed
- Container tab names are now correctly translated |
stonebuzz
requested changes
Jun 25, 2026
| $display_condition = new PluginFieldsContainerDisplayCondition(); | ||
| if ($display_condition->computeDisplayContainer($item, $data['id'])) { | ||
| $tabs_entries[$data['id']] = self::createTabEntry($data['label'], 0, null, PluginFieldsContainer::getIcon()); | ||
| $tabs_entries[$data['id']] = self::createTabEntry(PluginFieldsLabelTranslation::getLabelFor(array_merge($data, ['itemtype' => 'PluginFieldsContainer'])), 0, null, PluginFieldsContainer::getIcon()); |
Contributor
There was a problem hiding this comment.
Suggested change
| $tabs_entries[$data['id']] = self::createTabEntry(PluginFieldsLabelTranslation::getLabelFor(array_merge($data, ['itemtype' => 'PluginFieldsContainer'])), 0, null, PluginFieldsContainer::getIcon()); | |
| $label = PluginFieldsLabelTranslation::getLabelFor( | |
| array_merge($data, ['itemtype' => PluginFieldsContainer::class]) | |
| ); | |
| $tabs_entries[$data['id']] = self::createTabEntry($label, 0, null, PluginFieldsContainer::getIcon()); |
improves readability
Contributor
There was a problem hiding this comment.
getTabNameForItem has no test in tests/Units/. Can you add a test case where a container has a translation for the active session language and verify the translated label is returned, and another where no translation exists and the raw label value is returned as fallback?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Container tab names were displayed using $data['label'] directly without going through the translation system. This fix applies getLabelFor() to correctly display translated tab labels based on the user's language.
Fixes tab name translation not working when language is set to non-default.