Skip to content

Commit 0709a51

Browse files
committed
feat: create with vue-i18n
1 parent bdd66dc commit 0709a51

File tree

14 files changed

+97
-4
lines changed

14 files changed

+97
-4
lines changed

index.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ async function init() {
9797
'vue-router': { type: 'boolean' },
9898
router: { type: 'boolean' },
9999
'vue-devtools': { type: 'boolean' },
100-
devtools: { type: 'boolean' }
100+
devtools: { type: 'boolean' },
101+
'vue-i18n': { type: 'boolean' },
102+
i18n: { type: 'boolean' }
101103
} as const
102104

103105
const { values: argv, positionals } = parseArgs({
@@ -121,7 +123,9 @@ async function init() {
121123
argv.playwright ??
122124
argv.eslint ??
123125
argv['eslint-with-prettier'] ??
124-
(argv.devtools || argv['vue-devtools'])
126+
(argv.devtools || argv['vue-devtools']) ??
127+
argv['vue-i18n'] ??
128+
argv.i18n
125129
) === 'boolean'
126130

127131
let targetDir = positionals[0]
@@ -144,6 +148,7 @@ async function init() {
144148
needsEslint?: boolean
145149
needsPrettier?: boolean
146150
needsDevTools?: boolean
151+
needsVueI18n?: boolean
147152
} = {}
148153

149154
try {
@@ -300,6 +305,14 @@ async function init() {
300305
initial: false,
301306
active: language.defaultToggleOptions.active,
302307
inactive: language.defaultToggleOptions.inactive
308+
},
309+
{
310+
name: 'needsVueI18n',
311+
type: () => (isFeatureFlagsUsed ? null : 'toggle'),
312+
message: language.needsVueI18n.message,
313+
initial: false,
314+
active: language.defaultToggleOptions.active,
315+
inactive: language.defaultToggleOptions.inactive
303316
}
304317
],
305318
{
@@ -326,7 +339,8 @@ async function init() {
326339
needsVitest = argv.vitest || argv.tests,
327340
needsEslint = argv.eslint || argv['eslint-with-prettier'],
328341
needsPrettier = argv['eslint-with-prettier'],
329-
needsDevTools = argv.devtools || argv['vue-devtools']
342+
needsDevTools = argv.devtools || argv['vue-devtools'],
343+
needsVueI18n = argv['vue-i18n'] || argv.i18n
330344
} = result
331345

332346
const { needsE2eTesting } = result
@@ -474,6 +488,10 @@ async function init() {
474488
if (needsDevTools) {
475489
render('config/devtools')
476490
}
491+
492+
if (needsVueI18n) {
493+
render('config/vue-i18n')
494+
}
477495
// Render code template.
478496
// prettier-ignore
479497
const codeTemplate =
@@ -488,6 +506,8 @@ async function init() {
488506
render('entry/pinia')
489507
} else if (needsRouter) {
490508
render('entry/router')
509+
} else if (needsVueI18n) {
510+
render('entry/i18n')
491511
} else {
492512
render('entry/default')
493513
}
@@ -520,7 +540,7 @@ async function init() {
520540
// We try to share as many files between TypeScript and JavaScript as possible.
521541
// If that's not possible, we put `.ts` version alongside the `.js` one in the templates.
522542
// So after all the templates are rendered, we need to clean up the redundant files.
523-
// (Currently it's only `cypress/plugin/index.ts`, but we might add more in the future.)
543+
// (Currently it's only `cypress/plugin/index.js`, but we might add more in the future.)
524544
// (Or, we might completely get rid of the plugins folder as Cypress 10 supports `cypress.config.ts`)
525545

526546
if (needsTypeScript) {

locales/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"needsDevTools": {
5454
"message": "Add Vue DevTools 7 extension for debugging? (experimental)"
5555
},
56+
"needsVueI18n": {
57+
"message": "Add Vue I18n for internationalization?"
58+
},
5659
"errors": {
5760
"operationCancelled": "Operation cancelled"
5861
},

locales/fr-FR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"needsDevTools": {
5454
"message": "Ajouter l'extension Vue DevTools 7 pour le débogage\u00a0? (expérimental)"
5555
},
56+
"needsVueI18n": {
57+
"message": "Ajouter Vue I18n pour l'internationalisation\u00a0?"
58+
},
5659
"errors": {
5760
"operationCancelled": "Operation annulée"
5861
},

locales/tr-TR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"needsDevTools": {
5454
"message": "Hata ayıklama için Vue DevTools 7 eklentisi eklensin mi? (deneysel)"
5555
},
56+
"needsVueI18n": {
57+
"message": "Uluslararasılaştırma için Vue I18n eklensin mi?"
58+
},
5659
"errors": {
5760
"operationCancelled": "İşlem iptal edildi"
5861
},

locales/zh-Hans.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"needsDevTools": {
5454
"message": "是否引入 Vue DevTools 7 扩展用于调试? (试验阶段)"
5555
},
56+
"needsVueI18n": {
57+
"message": "是否引入 Vue I18n 用于国际化?"
58+
},
5659
"errors": {
5760
"operationCancelled": "操作取消"
5861
},

locales/zh-Hant.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
"needsDevTools": {
5858
"message": "是否引入 Vue DevTools 7 擴充元件以協助偵錯?(試驗性功能)"
5959
},
60+
"needsVueI18n": {
61+
"message": "是否引入 Vue I18n 用於國際化?"
62+
},
6063
"errors": {
6164
"operationCancelled": "操作取消"
6265
},

template/config/vue-i18n/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"vue": "^3.4.34",
4+
"vue-i18n": "^9.2.2"
5+
}
6+
}

template/config/vue-i18n/src/i18n/en.json

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createI18n } from 'vue-i18n'
2+
3+
const messages = {
4+
en: {
5+
// English Transtlations
6+
}
7+
}
8+
9+
export default createI18n({
10+
legacy: false,
11+
globalInjection: true,
12+
locale: 'en',
13+
fallbackLocale: 'en',
14+
messages
15+
})

template/entry/i18n/src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
import i18n from './main.js'
4+
5+
const app = createApp(App)
6+
app.use(i18n)
7+
app.mount('#app')

0 commit comments

Comments
 (0)