Merge commit 'eb816e4a781d4684b7859ddc05004fb28c199f31' into i18n

This commit is contained in:
Burt 2024-11-10 22:48:17 +08:00
commit 1b8ccc1ee3

View File

@ -34,9 +34,17 @@ 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 ''
}
}
/**
* formatI18n('我是{name},身高{detail.height},体重{detail.weight}',{name:'张三',detail:{height:178,weight:'75kg'}})