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

feat: support vue-i18n v9.1 #188

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tests/e2e/projects/vue-i18n-js/
tests/e2e/projects/vue-i18n-ts/
tests/output.json
.DS_Store
.env
*.log
*.swp
*~
2 changes: 1 addition & 1 deletion client-addon/.postcssrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module.exports = {
plugins: {
autoprefixer: {}
}
}
}
4 changes: 1 addition & 3 deletions client-addon/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
presets: ['@vue/cli-plugin-babel/preset']
}
13 changes: 8 additions & 5 deletions client-addon/public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>client-addon</title>
</head>
<body>
<noscript>
<strong>We're sorry but client-addon doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but client-addon doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
Expand Down
18 changes: 11 additions & 7 deletions client-addon/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { unflatten } from 'flat'

export function isObject (obj) {
export function isObject(obj) {
return obj !== null && typeof obj === 'object'
}

export function hasChildPaths (path, paths) {
if (!path) { return false }
export function hasChildPaths(path, paths) {
if (!path) {
return false
}

const localeMessages = unflatten(paths.reduce((val, path) => {
val[path] = ''
return val
}, {}))
const localeMessages = unflatten(
paths.reduce((val, path) => {
val[path] = ''
return val
}, {})
)
const splits = path.split('.')

// TODO: should be more strogly checking ...
Expand Down
4 changes: 2 additions & 2 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ module.exports = (api, options, rootOptions) => {
}

if (isVue3) {
pkg.dependencies['vue-i18n'] = '^9.0.0'
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^2.0.0'
pkg.dependencies['vue-i18n'] = '^9.1.0'
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^2.1.0'
pkg.vue.pluginOptions.i18n['enableLegacy'] = enableLegacy
pkg.vue.pluginOptions.i18n['runtimeOnly'] = false
pkg.vue.pluginOptions.i18n['compositionOnly'] = !!enableLegacy
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = (api, options) => {
{
__VUE_I18N_LEGACY_API__: legacyApiFlag,
__VUE_I18N_FULL_INSTALL__: installFlag,
__INTLIFY_PROD_DEVTOOLS__: 'false'
__VUE_I18N_PROD_DEVTOOLS__: 'false'
}
])
debug(
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/generator-vue3.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ test('javascript: legacy', async () => {
expect(sfc).toMatch(`import { defineComponent } from 'vue'`)
expect(sfc).toMatch(`export default defineComponent({`)
const pack = files['package.json']
expect(pack).toMatch(`"vue-i18n": "^9.0.0"`)
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.0.0"`)
expect(pack).toMatch(`"vue-i18n": "^9.1.0"`)
expect(pack).toMatch(`"@intlify/vue-i18n-loader": "^2.1.0"`)
})

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

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