Files
ArtPlayer/i18n/index.js
T
Harvey Zack 2fc9d4d3e9 Dep (#601)
* init

* update dep
2023-08-26 16:48:19 +08:00

31 lines
584 B
JavaScript

import { mergeDeep } from '../utils';
import zhCn from './zh-cn';
export default class I18n {
constructor(art) {
this.art = art;
this.languages = {
'zh-cn': zhCn,
};
this.language = {};
this.update(art.option.i18n);
}
init() {
const lang = this.art.option.lang.toLowerCase();
this.language = this.languages[lang] ?? {};
}
get(key) {
return this.language[key] ?? key;
}
update(value) {
this.languages = mergeDeep(this.languages, value);
this.init();
}
}