Skip to content

Commit

Permalink
fix(text-track-settings): localization not correctly applied
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amtins committed Oct 29, 2024
1 parent d2b9d5c commit 4768c18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/tracks/text-track-fieldset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/js/tracks/text-track-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TextTrackSelect extends Component {
{
id: optionId,
value: this.localize(optionText[0]),
textContent: optionText[1]
textContent: this.localize(optionText[1])
}
);

Expand Down
8 changes: 7 additions & 1 deletion test/unit/tracks/text-track-settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit 4768c18

Please sign in to comment.