Skip to content

Commit

Permalink
feat(i18n): 支持参数传递
Browse files Browse the repository at this point in the history
  • Loading branch information
codercup2 committed Feb 21, 2024
1 parent 6362422 commit 7a3edaf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
1 change: 1 addition & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"weight": "{heavy}KG",
"app.name": "En Title"
}
3 changes: 2 additions & 1 deletion src/locale/zh-Hans.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"app.name": "中文标题"
"app.name": "中文标题",
"weight": "{heavy}公斤"
}
1 change: 1 addition & 0 deletions src/pages/demo/page/i18n.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 7a3edaf

Please sign in to comment.