提交 11ebdc0f 编写于 作者: B baiy 提交者: ninecents

i18n fix

上级 91646f69
......@@ -43,6 +43,10 @@ const getLocale = (code) => {
if (file.indexOf('.i18n.json5') !== -1) {
let type = file.replace('.i18n.json5', '');
let config = JSON5.parse(fs.readFileSync(path.join(__dirname, `locales/${code}/${file}`), 'utf-8'));
// 写入区域
if (type === "main") {
locale[`${type}_locale`] = {message: code}
}
Object.keys(config).forEach(function (key) {
let placeholders = placeholder(config[key])
locale[`${type}_${key}`] = {
......@@ -129,7 +133,7 @@ module.exports = {
if (matchString) {
matchString.forEach((wildcard) => {
let key = wildcard.replace("{","").replace("}",'')
let key = wildcard.replace("{", "").replace("}", '')
if ((key in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[key]
}
......
......@@ -58,7 +58,7 @@ const translate = (code, key, values = {}) => {
if (matchString) {
matchString.forEach((wildcard) => {
let key = wildcard.replace("{","").replace("}",'')
let key = wildcard.replace("{", "").replace("}", '')
if ((key in values) && !(wildcard in replaceHash)) {
replaceHash[wildcard] = values[key]
}
......@@ -82,6 +82,11 @@ window["__"] = (key, values = {}, locale = null) => {
)
}
// 获取当前真实区域
export const getCurrentLocale = () => {
return __('main_locale').toString();
}
export const i18n = new VueI18n({
locale: 'zh_CN',
missing: (locale, key, vm, values) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册