Implement translation support for qualityName and qualityBadge

This commit is contained in:
Philip Giuliani
2018-05-30 14:55:48 +02:00
parent e0c09c51f2
commit 1c1668bfc3
2 changed files with 16 additions and 23 deletions

31
src/js/controls.js vendored
View File

@ -664,27 +664,7 @@ const controls = {
// Get the badge HTML for HD, 4K etc // Get the badge HTML for HD, 4K etc
const getBadge = quality => { const getBadge = quality => {
let label = ''; const label = i18n.get(`qualityBadge.${quality}`, this.config);
switch (quality) {
case 2160:
label = '4K';
break;
case 1440:
case 1080:
case 720:
label = 'HD';
break;
case 576:
case 480:
label = 'SD';
break;
default:
break;
}
if (!label.length) { if (!label.length) {
return null; return null;
@ -708,7 +688,6 @@ const controls = {
}, },
// Translate a value into a nice label // Translate a value into a nice label
// TODO: Localisation
getLabel(setting, value) { getLabel(setting, value) {
switch (setting) { switch (setting) {
case 'speed': case 'speed':
@ -716,7 +695,13 @@ const controls = {
case 'quality': case 'quality':
if (utils.is.number(value)) { if (utils.is.number(value)) {
return `${value}p`; const qualityName = i18n.get(`qualityName.${value}`, this.config);
if (!qualityName.length) {
return `${value}p`;
}
return qualityName;
} }
return utils.toTitleCase(value); return utils.toTitleCase(value);

View File

@ -190,6 +190,14 @@ const defaults = {
disabled: 'Disabled', disabled: 'Disabled',
enabled: 'Enabled', enabled: 'Enabled',
advertisement: 'Ad', advertisement: 'Ad',
qualityBadge: {
2160: '4K',
1440: 'HD',
1080: 'HD',
720: 'HD',
576: 'SD',
480: 'SD',
},
}, },
// URLs // URLs