Initial commit of akmon project
This commit is contained in:
14
utils/i18nfun.uts
Normal file
14
utils/i18nfun.uts
Normal file
@@ -0,0 +1,14 @@
|
||||
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: '张三'})
|
||||
Reference in New Issue
Block a user