File tree Expand file tree Collapse file tree 7 files changed +113
-9
lines changed Expand file tree Collapse file tree 7 files changed +113
-9
lines changed Original file line number Diff line number Diff line change 26
26
"vant" : " 4.9.17" ,
27
27
"vconsole" : " 3.15.1" ,
28
28
"vue" : " 3.5.13" ,
29
+ "vue-i18n" : " 11.1.1" ,
29
30
"vue-router" : " 4.5.0"
30
31
},
31
32
"devDependencies" : {
Original file line number Diff line number Diff line change 1
- <script setup lang="ts"></script >
1
+ <script setup lang="ts">
2
+ import { Locale } from " vant"
3
+ import enUS from " vant/es/locale/lang/en-US"
4
+ import { useI18n } from " vue-i18n"
5
+ import NoticeBar from " ./components/NoticeBar.vue"
6
+
7
+ const { t, locale } = useI18n ()
8
+
9
+ const checked = ref <string >(locale .value )
10
+
11
+ function onChange(name : string ) {
12
+ locale .value = name
13
+ name === " en" ? Locale .use (" en-US" , enUS ) : Locale .use (" zh-CN" )
14
+ }
15
+ </script >
2
16
3
17
<template >
4
- <van-empty description =" 作者正在努力,点个 Star 为作者加速!" />
18
+ <div un-mb-20px >
19
+ <NoticeBar :text =" t('text')" />
20
+ <van-radio-group v-model =" checked" @change =" onChange" >
21
+ <van-cell-group :title =" t('title')" inset >
22
+ <van-cell title =" 中文" @click =" checked = 'zh-CN'" >
23
+ <template #right-icon >
24
+ <van-radio name =" zh-CN" />
25
+ </template >
26
+ </van-cell >
27
+ <van-cell title =" English" @click =" checked = 'en'" >
28
+ <template #right-icon >
29
+ <van-radio name =" en" />
30
+ </template >
31
+ </van-cell >
32
+ </van-cell-group >
33
+ </van-radio-group >
34
+ <van-calendar
35
+ :poppable =" false"
36
+ :show-confirm =" false"
37
+ un-h-500px
38
+ un-mx-16px
39
+ un-my-20px
40
+ un-rounded-8px
41
+ un-overflow-hidden
42
+ />
43
+ </div >
5
44
</template >
Original file line number Diff line number Diff line change
1
+ import type { App } from "vue"
2
+ import { createI18n } from "vue-i18n"
3
+
4
+ const i18n = createI18n ( {
5
+ locale : "zh-CN" ,
6
+ fallbackLocale : "zh-CN" ,
7
+ messages : {
8
+ "zh-CN" : {
9
+ text : "现在语言环境为中文" ,
10
+ title : "切换语言"
11
+ } ,
12
+ "en" : {
13
+ text : "The current language is English" ,
14
+ title : "Switch language"
15
+ }
16
+ }
17
+ } )
18
+
19
+ export function installI18n ( app : App ) {
20
+ app . use ( i18n )
21
+ }
Original file line number Diff line number Diff line change 1
1
import type { App } from "vue"
2
2
import { installConsole } from "./console"
3
+ import { installI18n } from "./i18n"
3
4
import { installPermissionDirective } from "./permission-directive"
4
5
5
6
export function installPlugins ( app : App ) {
6
7
installPermissionDirective ( app )
7
8
installConsole ( )
9
+ installI18n ( app )
8
10
}
Original file line number Diff line number Diff line change @@ -143,25 +143,25 @@ export const demoRoutes: RouteRecordRaw[] = [
143
143
}
144
144
}
145
145
}
146
- }
147
- ]
148
-
149
- /** 空示例页面 */
150
- export const emptyDemoRoutes : RouteRecordRaw [ ] = [
146
+ } ,
151
147
{
152
148
path : "/i18n" ,
153
149
component : ( ) => import ( "@/pages/demo/i18n.vue" ) ,
154
150
name : "I18n" ,
155
151
meta : {
156
- title : "国际化 / 多语言 " ,
152
+ title : "国际化 / i18n " ,
157
153
layout : {
158
154
navBar : {
159
155
showNavBar : true ,
160
156
showLeftArrow : true
161
157
}
162
158
}
163
159
}
164
- } ,
160
+ }
161
+ ]
162
+
163
+ /** 空示例页面 */
164
+ export const emptyDemoRoutes : RouteRecordRaw [ ] = [
165
165
{
166
166
path : "/markdown" ,
167
167
component : ( ) => import ( "@/pages/demo/markdown.vue" ) ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ declare module 'vue' {
11
11
RouterLink : typeof import ( 'vue-router' ) [ 'RouterLink' ]
12
12
RouterView : typeof import ( 'vue-router' ) [ 'RouterView' ]
13
13
VanButton : typeof import ( 'vant/es' ) [ 'Button' ]
14
+ VanCalendar : typeof import ( 'vant/es' ) [ 'Calendar' ]
14
15
VanCell : typeof import ( 'vant/es' ) [ 'Cell' ]
15
16
VanCellGroup : typeof import ( 'vant/es' ) [ 'CellGroup' ]
16
17
VanConfigProvider : typeof import ( 'vant/es' ) [ 'ConfigProvider' ]
You can’t perform that action at this time.
0 commit comments