New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve localisation #1873
Improve localisation #1873
Changes from 1 commit
679598a
c0617a9
0e63261
6128305
2fc8968
349ff89
2bf0be7
77fc23e
0208712
f8b0fb1
11303fc
34c1a7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,12 @@ vjs.Player = vjs.Component.extend({ | |
this.language_ = options['language'] || vjs.options['language']; | ||
|
||
// Update Supported Languages | ||
this.languages_ = options['languages'] || vjs.options['languages']; | ||
var languages = vjs.obj.copy(options['languages'] || vjs.options['languages']); | ||
vjs.options['languages'] = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you taking the player level language definitions and copying them out to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong solution to the problem. Or solution to the wrong problem. I need to rework that. I've now realised that although There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok. There are two levels of options in video.js: page-level and player-level. I believe this code was originally intending to use player-level language settings if provided and fall back to the page-level language settings otherwise. |
||
vjs.obj.each(languages, function(name, value) { | ||
vjs.addLanguage(name, languages[name]); | ||
}); | ||
this.languages_ = vjs.options['languages']; | ||
|
||
// Cache for video property values. | ||
this.cache_ = {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -590,3 +590,27 @@ test('should provide interval methods that automatically get cleared on componen | |
|
||
ok(intervalsFired === 5, 'Interval was cleared when component was disposed'); | ||
}); | ||
|
||
test('should ignore case in language codes and try primary code', function() { | ||
expect(3); | ||
|
||
var player = PlayerTest.makePlayer({ | ||
'languages': { | ||
'en-gb': { | ||
'Good': 'Brilliant' | ||
}, | ||
'EN': { | ||
'Good': 'Awesome', | ||
'Error': 'Problem' | ||
} | ||
} | ||
}); | ||
|
||
var comp = new vjs.Component(player); | ||
|
||
player.language('en-gb'); | ||
ok(comp.localize('Good') === 'Brilliant', 'Used subcode specific localization'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
ok(comp.localize('Error') === 'Problem', 'Used primary code localization'); | ||
player.language('en-GB'); | ||
ok(comp.localize('Good') === 'Brilliant', 'Ignored case'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I think no one likes it at this point, most of the rest of the code declares variables at the top of the scope.