This commit is contained in:
syuilo
2018-02-10 10:27:05 +09:00
parent d5f345c8f9
commit ff7bb97d8e
19 changed files with 58 additions and 146 deletions

View File

@ -17,12 +17,19 @@ export default class Replacer {
}
private get(key: string) {
let text = locale[this.lang];
const texts = locale[this.lang];
if (texts == null) {
console.warn(`lang '${this.lang}' is not supported`);
return key; // Fallback
}
let text;
// Check the key existance
const error = key.split('.').some(k => {
if (text.hasOwnProperty(k)) {
text = text[k];
if (texts.hasOwnProperty(k)) {
text = texts[k];
return false;
} else {
return true;