Allow nested translations

This commit is contained in:
Philip Giuliani 2018-05-30 14:55:29 +02:00
parent 8de06fb862
commit e0c09c51f2

View File

@ -6,11 +6,15 @@ import utils from './utils';
const i18n = { const i18n = {
get(key = '', config = {}) { get(key = '', config = {}) {
if (utils.is.empty(key) || utils.is.empty(config) || !Object.keys(config.i18n).includes(key)) { if (utils.is.empty(key) || utils.is.empty(config)) {
return ''; return '';
} }
let string = config.i18n[key]; let string = key.split('.').reduce((o,i) => o[i] || {}, config.i18n);
if (utils.is.empty(string)) {
return '';
}
const replace = { const replace = {
'{seektime}': config.seekTime, '{seektime}': config.seekTime,