diff --git a/src/i18n.d.ts b/src/i18n.d.ts index e050b53..b9c76e3 100644 --- a/src/i18n.d.ts +++ b/src/i18n.d.ts @@ -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 + $tm: (key: string, opt?: Record) => [] | { [p: string]: any } } } diff --git a/src/locale/en.json b/src/locale/en.json index 9eaddd2..1973f89 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -1,3 +1,4 @@ { + "weight": "{heavy}KG", "app.name": "En Title" } diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index b1ba111..bd397a1 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -1,3 +1,4 @@ { - "app.name": "中文标题" + "app.name": "中文标题", + "weight": "{heavy}公斤" } diff --git a/src/pages/demo/page/i18n.vue b/src/pages/demo/page/i18n.vue index 033cd8d..d81c964 100644 --- a/src/pages/demo/page/i18n.vue +++ b/src/pages/demo/page/i18n.vue @@ -11,6 +11,7 @@ 多语言测试 {{ $t('app.name') }} + {{ $t('weight', { heavy: 100 }) }} 切换语言