@aliyun-obv/i18n
Advanced tools
Comparing version 0.0.4 to 0.0.5
declare function getMsg(key: string): any; | ||
declare const BaseI18n: { | ||
declare const I18n: { | ||
NODATA: any; | ||
@@ -39,2 +39,2 @@ SELECTALL: any; | ||
export { BaseI18n as default, getMsg, replaceI18nVariable }; | ||
export { I18n as default, getMsg, replaceI18nVariable }; |
@@ -0,2 +1,54 @@ | ||
const import_meta = {}; | ||
let mdsRemoteI18n = {}; | ||
if (__VITE__) { | ||
if (process.env.NODE_ENV === "development") { | ||
try { | ||
mdsRemoteI18n = import_meta.glob(`./i18n.json`, { eager: true })["./i18n.json"]; | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
} | ||
const descriptions = { | ||
zh: { | ||
mcmsKey: "zh_CN" | ||
}, | ||
en: { | ||
mcmsKey: "en_US" | ||
}, | ||
ja: { | ||
mcmsKey: "ja_JP" | ||
}, | ||
zh_TW: { | ||
mcmsKey: "zh_TW" | ||
} | ||
}; | ||
const init = () => { | ||
var _a; | ||
if (process.env.IGNORE_I18N) { | ||
return; | ||
} | ||
const lang = "zh"; | ||
const desc = (_a = descriptions[lang]) != null ? _a : descriptions.en; | ||
const cacheRemoteMDS = mdsRemoteI18n && mdsRemoteI18n[desc.mcmsKey] || {}; | ||
if (window["sls-console-aliyun-com"]) { | ||
console.info("use mcms lang success."); | ||
window.ALIYUN_SLS_CONSOLE_MESSAGE = Object.assign( | ||
cacheRemoteMDS, | ||
window["sls-console-aliyun-com"][desc.mcmsKey] || {} | ||
); | ||
} else { | ||
window.ALIYUN_SLS_CONSOLE_MESSAGE = Object.assign( | ||
cacheRemoteMDS, | ||
window.ALIYUN_SLS_CONSOLE_MESSAGE || {} | ||
); | ||
} | ||
}; | ||
let hasInit = false; | ||
function getMsg(key) { | ||
if (!hasInit) { | ||
init(); | ||
hasInit = true; | ||
} | ||
if (process.env.IGNORE_I18N) { | ||
@@ -11,3 +63,3 @@ return ""; | ||
} | ||
const BaseI18n = { | ||
const I18n = { | ||
NODATA: getMsg("msg.no_data"), | ||
@@ -85,3 +137,3 @@ SELECTALL: getMsg("lb.select_all"), | ||
export { BaseI18n as default, getMsg, replaceI18nVariable }; | ||
export { I18n as default, getMsg, replaceI18nVariable }; | ||
//# sourceMappingURL=i18n.es.js.map |
@@ -11,3 +11,3 @@ { | ||
"devDependencies": {}, | ||
"version": "0.0.4" | ||
"version": "0.0.5" | ||
} |
4432
173