Skip to content

Commit 2221ecf

Browse files
committed
feat: initial setup and testing for i18n support in create-vue project
1 parent 7e7e516 commit 2221ecf

File tree

22 files changed

+3573
-8
lines changed

22 files changed

+3573
-8
lines changed

__test__/sortDependencies.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('sortDependencies', () => {
2121
'eslint-plugin-cypress': '^2.15.1',
2222
'eslint-plugin-vue': '^9.17.0',
2323
vitest: '^0.34.6',
24+
'vue-i18n': '^11.1.7',
2425
},
2526
}
2627
expect(sortDependencies(packageJson)).toStrictEqual({
@@ -41,6 +42,7 @@ describe('sortDependencies', () => {
4142
'start-server-and-test': '^2.0.1',
4243
vite: '^4.4.11',
4344
vitest: '^0.34.6',
45+
'vue-i18n': '^11.1.7',
4446
},
4547
})
4648
})

index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const FEATURE_FLAGS = [
4242
'eslint-with-prettier',
4343
'oxlint',
4444
'rolldown-vite',
45+
'i18n',
4546
] as const
4647

4748
const FEATURE_OPTIONS = [
@@ -77,6 +78,10 @@ const FEATURE_OPTIONS = [
7778
value: 'prettier',
7879
label: language.needsPrettier.message,
7980
},
81+
{
82+
value: 'i18n',
83+
label: language.needsVueI18n.message,
84+
},
8085
] as const
8186
const EXPERIMENTAL_FEATURE_OPTIONS = [
8287
{
@@ -176,6 +181,8 @@ Available feature flags:
176181
Add Vue Router for SPA development.
177182
--pinia
178183
Add Pinia for state management.
184+
--i18n
185+
Add Vue I18n for internationalization.
179186
--vitest
180187
Add Vitest for unit testing.
181188
--cypress
@@ -353,6 +360,7 @@ async function init() {
353360
const needsJsx = argv.jsx || features.includes('jsx')
354361
const needsRouter = argv.router || argv['vue-router'] || features.includes('router')
355362
const needsPinia = argv.pinia || features.includes('pinia')
363+
const needsVueI18n = argv.i18n || features.includes('i18n')
356364
const needsVitest = argv.vitest || argv.tests || features.includes('vitest')
357365
const needsEslint = argv.eslint || argv['eslint-with-prettier'] || features.includes('eslint')
358366
const needsPrettier =
@@ -406,6 +414,9 @@ async function init() {
406414
if (needsPinia) {
407415
render('config/pinia')
408416
}
417+
if (needsVueI18n) {
418+
render('config/vue-i18n')
419+
}
409420
if (needsVitest) {
410421
render('config/vitest')
411422
}
@@ -524,12 +535,20 @@ async function init() {
524535
render(`code/${codeTemplate}`)
525536

526537
// Render entry file (main.js/ts).
527-
if (needsPinia && needsRouter) {
538+
if (needsPinia && needsRouter && needsVueI18n) {
539+
render('entry/pinia-router-and-i18n')
540+
} else if (needsRouter && needsVueI18n) {
541+
render('entry/router-and-i18n')
542+
} else if (needsPinia && needsVueI18n) {
543+
render('entry/pinia-and-i18n')
544+
} else if (needsPinia && needsRouter) {
528545
render('entry/router-and-pinia')
529546
} else if (needsPinia) {
530547
render('entry/pinia')
531548
} else if (needsRouter) {
532549
render('entry/router')
550+
} else if (needsVueI18n) {
551+
render('entry/i18n')
533552
} else {
534553
render('entry/default')
535554
}

locales/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"needsRolldownVite": {
7373
"message": "rolldown-vite (experimental)"
7474
},
75+
"needsVueI18n": {
76+
"message": "Add Vue I18n for internationalization?"
77+
},
7578
"errors": {
7679
"operationCancelled": "Operation cancelled"
7780
},

locales/fr-FR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"needsRolldownVite": {
7373
"message": "rolldown-vite (expérimental)"
7474
},
75+
"needsVueI18n": {
76+
"message": "Ajouter Vue I18n pour l'internationalisation\u00a0?"
77+
},
7578
"errors": {
7679
"operationCancelled": "Operation annulée"
7780
},

locales/tr-TR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"needsRolldownVite": {
7373
"message": "rolldown-vite (deneysel)"
7474
},
75+
"needsVueI18n": {
76+
"message": "Uluslararasılaştırma için Vue I18n eklensin mi?"
77+
},
7578
"errors": {
7679
"operationCancelled": "İşlem iptal edildi"
7780
},

locales/zh-Hans.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
"errors": {
7676
"operationCancelled": "操作取消"
7777
},
78+
"needsVueI18n": {
79+
"message": "是否引入 Vue I18n 用于国际化?"
80+
},
7881
"defaultToggleOptions": {
7982
"active": "",
8083
"inactive": ""

locales/zh-Hant.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"needsRolldownVite": {
7373
"message": "rolldown-vite(試驗性功能)"
7474
},
75+
"needsVueI18n": {
76+
"message": "是否引入 Vue I18n 用於國際化?"
77+
},
7578
"errors": {
7679
"operationCancelled": "操作取消"
7780
},

0 commit comments

Comments
 (0)