Allow nested translations
This commit is contained in:
parent
8de06fb862
commit
e0c09c51f2
@ -6,11 +6,15 @@ import utils from './utils';
|
||||
|
||||
const i18n = {
|
||||
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 '';
|
||||
}
|
||||
|
||||
let string = config.i18n[key];
|
||||
let string = key.split('.').reduce((o,i) => o[i] || {}, config.i18n);
|
||||
|
||||
if (utils.is.empty(string)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const replace = {
|
||||
'{seektime}': config.seekTime,
|
||||
|
Loading…
x
Reference in New Issue
Block a user