15 lines
483 B
Plaintext
15 lines
483 B
Plaintext
import i18n from '@/i18n/index.uts'
|
|
|
|
// 包装一个带参数智能判断的 t 函数,支持缺省值
|
|
export function tt(key: string, values: any | null = null, locale: string | null = null): string {
|
|
const isLocale = typeof values === 'string'
|
|
const _values = isLocale ? null : values
|
|
const _locale = isLocale ? values : locale
|
|
return i18n.global.t(key, _values, _locale)
|
|
}
|
|
|
|
// 示例用法
|
|
// tSmart('prev')
|
|
// tSmart('prev', 'en-US')
|
|
// tSmart('prev', {name: '张三'})
|