feat: 支持多语言文件深层写法
This commit is contained in:
parent
deda75ffdd
commit
eb816e4a78
@ -34,8 +34,16 @@ export const getTemplateByKey = (key: string) => {
|
||||
if (Object.keys(message).includes(key)) {
|
||||
return message[key]
|
||||
}
|
||||
|
||||
try {
|
||||
const keyList = key.split('.')
|
||||
return keyList.reduce((pre, cur) => {
|
||||
return pre[cur]
|
||||
}, message)
|
||||
} catch (error) {
|
||||
console.error(`[i18n] Function getTemplateByKey(), key param ${key} is not existed.`)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user