mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 09:20:51 +08:00
24 lines
473 B
TypeScript
24 lines
473 B
TypeScript
import defaultLang from './lang/en'
|
|
|
|
let lang = defaultLang
|
|
|
|
export const t = (path:string): string => {
|
|
let value
|
|
const array = path.split('.')
|
|
let current = lang
|
|
for (let i = 0, j = array.length; i < j; i++) {
|
|
const property = array[i]
|
|
value = current[property] || property
|
|
if (i === j - 1) return value
|
|
if (!value) return ''
|
|
current = value
|
|
}
|
|
return ''
|
|
}
|
|
|
|
export const use = (l): void => {
|
|
lang = l || lang
|
|
}
|
|
|
|
export default { use, t }
|