add i18n for console logs
This commit is contained in:
parent
b170a532f6
commit
7752585488
14 changed files with 77 additions and 31 deletions
|
@ -19,7 +19,7 @@ export default function init(lang) {
|
|||
|
||||
i18n.lang = language;
|
||||
i18n.lang_code = lang;
|
||||
i18n.string = function(/* @type string */ key) {
|
||||
i18n.string = function(/* @type string */ key, ...args) {
|
||||
const tokens = key.split('.');
|
||||
|
||||
let i = 0;
|
||||
|
@ -32,10 +32,20 @@ export default function init(lang) {
|
|||
return key;
|
||||
}
|
||||
if (typeof res === 'string' || res instanceof String)
|
||||
return res;
|
||||
break;
|
||||
i++;
|
||||
token = tokens[i];
|
||||
}
|
||||
|
||||
i = 1;
|
||||
while (true) {
|
||||
if (args.length < i || !res.includes('%' + i))
|
||||
break;
|
||||
res = res.replaceAll('%' + i, args[i - 1]);
|
||||
i++;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
i18n.stringArray = function(/* @type string */ key) {
|
||||
const tokens = key.split('.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue