summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-15 01:20:46 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-15 01:20:46 +0900
commita16dffbd7573f724ea0d7b104d0618a319b0fa17 (patch)
tree139da8466b56779bbfbf1feea4dbb07b2ec5f808
parentwip (diff)
downloadsharkey-a16dffbd7573f724ea0d7b104d0618a319b0fa17.tar.gz
sharkey-a16dffbd7573f724ea0d7b104d0618a319b0fa17.tar.bz2
sharkey-a16dffbd7573f724ea0d7b104d0618a319b0fa17.zip
wip
-rw-r--r--src/build/i18n.ts22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/build/i18n.ts b/src/build/i18n.ts
index d9dacccd34..1fb43a13c9 100644
--- a/src/build/i18n.ts
+++ b/src/build/i18n.ts
@@ -16,7 +16,7 @@ export default class Replacer {
this.replacement = this.replacement.bind(this);
}
- private get(key: string) {
+ private get(path: string, key: string) {
const texts = locale[this.lang];
if (texts == null) {
@@ -26,6 +26,15 @@ export default class Replacer {
let text = texts;
+ if (path) {
+ if (text.hasOwnProperty(path)) {
+ text = text[path];
+ } else {
+ console.warn(`path '${path}' not found in '${this.lang}'`);
+ return key; // Fallback
+ }
+ }
+
// Check the key existance
const error = key.split('.').some(k => {
if (text.hasOwnProperty(k)) {
@@ -37,7 +46,7 @@ export default class Replacer {
});
if (error) {
- console.warn(`key '${key}' not found in '${this.lang}'`);
+ console.warn(`key '${key}' not found in '${path}' of '${this.lang}'`);
return key; // Fallback
} else {
return text;
@@ -51,18 +60,17 @@ export default class Replacer {
let key = a || b || c;
if (key[0] == '@') {
- const prefix = name.split('.')[0].replace(/\//g, '.') + '.';
//if (name.startsWith('app/desktop/views/')) prefix = 'desktop.views.';
//if (name.startsWith('app/mobile/views/')) prefix = 'mobile.views.';
- key = prefix + key.substr(1);
+ key = key.substr(1);
}
if (match[0] == '"') {
- return '"' + this.get(key).replace(/"/g, '\\"') + '"';
+ return '"' + this.get(name, key).replace(/"/g, '\\"') + '"';
} else if (match[0] == "'") {
- return '\'' + this.get(key).replace(/'/g, '\\\'') + '\'';
+ return '\'' + this.get(name, key).replace(/'/g, '\\\'') + '\'';
} else {
- return this.get(key);
+ return this.get(name, key);
}
}
}