feat(i18n): 支持参数传递

This commit is contained in:
菲鸽 2024-02-21 11:17:03 +08:00
parent 6362422f5a
commit 7a3edaf816
4 changed files with 6 additions and 3 deletions

4
src/i18n.d.ts vendored
View File

@ -3,7 +3,7 @@ export {}
declare module 'vue' {
interface ComponentCustomProperties {
$t: (key: string) => string
$tm: (key: string) => [] | { [p: string]: any }
$t: (key: string, opt?: Record<string, any>) => string
$tm: (key: string, opt?: Record<string, any>) => [] | { [p: string]: any }
}
}

View File

@ -1,3 +1,4 @@
{
"weight": "{heavy}KG",
"app.name": "En Title"
}

View File

@ -1,3 +1,4 @@
{
"app.name": "中文标题"
"app.name": "中文标题",
"weight": "{heavy}公斤"
}

View File

@ -11,6 +11,7 @@
<view class="center flex-col mt-6">
<view class="text-green-500">多语言测试</view>
<view class="m-4">{{ $t('app.name') }}</view>
<view class="m-4">{{ $t('weight', { heavy: 100 }) }}</view>
<view class="text-green-500 mt-12">切换语言 </view>
<view class="uni-list">