Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 21d5b56

Browse files
authored
feat: support vue-i18n v9.1 (#188)
1 parent 9813825 commit 21d5b56

File tree

8 files changed

+31
-25
lines changed

8 files changed

+31
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ tests/e2e/projects/vue-i18n-js/
44
tests/e2e/projects/vue-i18n-ts/
55
tests/output.json
66
.DS_Store
7+
.env
78
*.log
89
*.swp
910
*~

client-addon/.postcssrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module.exports = {
22
plugins: {
33
autoprefixer: {}
44
}
5-
}
5+
}

client-addon/babel.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
presets: [
3-
'@vue/cli-plugin-babel/preset'
4-
]
2+
presets: ['@vue/cli-plugin-babel/preset']
53
}

client-addon/public/index.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
88
<title>client-addon</title>
99
</head>
1010
<body>
1111
<noscript>
12-
<strong>We're sorry but client-addon doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
12+
<strong
13+
>We're sorry but client-addon doesn't work properly without JavaScript
14+
enabled. Please enable it to continue.</strong
15+
>
1316
</noscript>
1417
<div id="app"></div>
1518
<!-- built files will be auto injected -->

client-addon/src/utils.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { unflatten } from 'flat'
22

3-
export function isObject (obj) {
3+
export function isObject(obj) {
44
return obj !== null && typeof obj === 'object'
55
}
66

7-
export function hasChildPaths (path, paths) {
8-
if (!path) { return false }
7+
export function hasChildPaths(path, paths) {
8+
if (!path) {
9+
return false
10+
}
911

10-
const localeMessages = unflatten(paths.reduce((val, path) => {
11-
val[path] = ''
12-
return val
13-
}, {}))
12+
const localeMessages = unflatten(
13+
paths.reduce((val, path) => {
14+
val[path] = ''
15+
return val
16+
}, {})
17+
)
1418
const splits = path.split('.')
1519

1620
// TODO: should be more strogly checking ...

generator/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ module.exports = (api, options, rootOptions) => {
5252
}
5353

5454
if (isVue3) {
55-
pkg.dependencies['vue-i18n'] = '^9.0.0'
56-
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^2.0.0'
55+
pkg.dependencies['vue-i18n'] = '^9.1.0'
56+
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^2.1.0'
5757
pkg.vue.pluginOptions.i18n['enableLegacy'] = enableLegacy
5858
pkg.vue.pluginOptions.i18n['runtimeOnly'] = false
5959
pkg.vue.pluginOptions.i18n['compositionOnly'] = !!enableLegacy

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = (api, options) => {
5959
{
6060
__VUE_I18N_LEGACY_API__: legacyApiFlag,
6161
__VUE_I18N_FULL_INSTALL__: installFlag,
62-
__INTLIFY_PROD_DEVTOOLS__: 'false'
62+
__VUE_I18N_PROD_DEVTOOLS__: 'false'
6363
}
6464
])
6565
debug(

tests/unit/generator-vue3.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ test('javascript: legacy', async () => {
2828
expect(sfc).toMatch(`import { defineComponent } from 'vue'`)
2929
expect(sfc).toMatch(`export default defineComponent({`)
3030
const pack = files['package.json']
31-
expect(pack).toMatch(`"vue-i18n": "^9.0.0"`)
32-
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.0.0"`)
31+
expect(pack).toMatch(`"vue-i18n": "^9.1.0"`)
32+
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.1.0"`)
3333
})
3434

3535
test('javascript: composition', async () => {
@@ -62,8 +62,8 @@ test('javascript: composition', async () => {
6262
expect(sfc).toMatch(`export default defineComponent({`)
6363
expect(sfc).toMatch(`const { t } = useI18n({`)
6464
const pack = files['package.json']
65-
expect(pack).toMatch(`"vue-i18n": "^9.0.0"`)
66-
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.0.0"`)
65+
expect(pack).toMatch(`"vue-i18n": "^9.1.0"`)
66+
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.1.0"`)
6767
})
6868

6969
test('typescript: composition', async () => {
@@ -107,6 +107,6 @@ test('typescript: composition', async () => {
107107
expect(sfc).toMatch(`export default defineComponent({`)
108108
expect(sfc).toMatch(`const { t } = useI18n({`)
109109
const pack = files['package.json']
110-
expect(pack).toMatch(`"vue-i18n": "^9.0.0"`)
111-
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.0.0"`)
110+
expect(pack).toMatch(`"vue-i18n": "^9.1.0"`)
111+
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.1.0"`)
112112
})

0 commit comments

Comments
 (0)