From 4768c18fe3f146eca8e06e7f9b3dcfba08d2f5b5 Mon Sep 17 00:00:00 2001 From: amtins Date: Tue, 29 Oct 2024 19:38:03 +0100 Subject: [PATCH] fix(text-track-settings): localization not correctly applied Localization is not applied correctly in fieldset labels and select options. As a result, the text track setting modal dialog is only half translated. - add `localize` at `label` level in `TextTrackFieldset` - add `localize` at `option` level in `TextTrackSelect` - add test cases --- src/js/tracks/text-track-fieldset.js | 2 +- src/js/tracks/text-track-select.js | 2 +- test/unit/tracks/text-track-settings.test.js | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/js/tracks/text-track-fieldset.js b/src/js/tracks/text-track-fieldset.js index b8f69df9f3..945c21cf62 100644 --- a/src/js/tracks/text-track-fieldset.js +++ b/src/js/tracks/text-track-fieldset.js @@ -87,7 +87,7 @@ class TextTrackFieldset extends Component { const label = Dom.createEl('label', { id, className: 'vjs-label', - textContent: selectConfig.label + textContent: this.localize(selectConfig.label) }); label.setAttribute('for', guid); diff --git a/src/js/tracks/text-track-select.js b/src/js/tracks/text-track-select.js index 288bc55b7a..99bb538ee3 100644 --- a/src/js/tracks/text-track-select.js +++ b/src/js/tracks/text-track-select.js @@ -68,7 +68,7 @@ class TextTrackSelect extends Component { { id: optionId, value: this.localize(optionText[0]), - textContent: optionText[1] + textContent: this.localize(optionText[1]) } ); diff --git a/test/unit/tracks/text-track-settings.test.js b/test/unit/tracks/text-track-settings.test.js index e20a93664a..1eec3e6aef 100644 --- a/test/unit/tracks/text-track-settings.test.js +++ b/test/unit/tracks/text-track-settings.test.js @@ -375,10 +375,16 @@ QUnit.test('should update on languagechange', function(assert) { tracks }); - videojs.addLanguage('test', {'Font Size': 'FONTSIZE'}); + videojs.addLanguage('test', { + 'Font Size': 'FONTSIZE', + 'Color': 'COLOR', + 'White': 'WHITE' + }); player.language('test'); assert.equal(player.$('.vjs-font-percent legend').textContent, 'FONTSIZE', 'settings dialog updates on languagechange'); + assert.equal(player.$('.vjs-text-color label').textContent, 'COLOR', 'settings dialog label updates on languagechange'); + assert.equal(player.$('.vjs-text-color select option').textContent, 'WHITE', 'settings dialog select updates on languagechange'); player.dispose(); });