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

Commit

Permalink
feat: includeLocales option (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Sep 30, 2021
1 parent 716d586 commit deb6f8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ module.exports = {

Whether to set up a birdge to migrate to `vue-i18n@v9.x` from `vue-i18n@v8.26`, Default `No` in prompt.

### `includeLocales`

- **Type:** `boolean`
- **Default in prompt:** `false`
- **Support project Vue version:** Vue 2 only

When `enableBridge` is `true`, i.e. in birdge mode, whether localization messags placed in `localeDir` option should be pre-compiled by message compiler or not.

If you use Composition API in bridge mode, this option must be `true` because all localization messages are bundled during production build.

### `runtimeOnly`
- **Type:** `boolean`
- **Default(No Prompt):** `false`
Expand Down
1 change: 1 addition & 0 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module.exports = (api, options, rootOptions) => {
if (enableBridge) {
pkg.devDependencies['@intlify/vue-i18n-loader'] = '^3.2.0'
pkg.dependencies['vue-i18n-bridge'] = '^9.2.0-beta.10'
pkg.vue.pluginOptions.i18n['includeLocales'] = false
}
pkg.vue.pluginOptions.i18n['enableBridge'] = enableBridge
}
Expand Down
21 changes: 12 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = (api, options) => {
runtimeOnly,
enableLegacy,
enableBridge,
includeLocales,
compositionOnly,
fullInstall
} = options.pluginOptions.i18n
Expand Down Expand Up @@ -86,15 +87,17 @@ module.exports = (api, options) => {
.end()
} else {
// prettier-ignore
webpackConfig.module
.rule('i18n-resource')
.test(/\.(json5?|ya?ml)$/)
.include.add(path.resolve(__dirname, '../../', `./src/${localeDir}`))
.end()
.type('javascript/auto')
.use('i18n-resource')
.loader('@intlify/vue-i18n-loader')
.options({ bridge: true })
if (includeLocales) {
webpackConfig.module
.rule('i18n-resource')
.test(/\.(json5?|ya?ml)$/)
.include.add(path.resolve(__dirname, '../../', `./src/${localeDir}`))
.end()
.type('javascript/auto')
.use('i18n-resource')
.loader('@intlify/vue-i18n-loader')
.options({ bridge: true })
}
// prettier-ignore
webpackConfig.module
.rule('i18n')
Expand Down

0 comments on commit deb6f8e

Please sign in to comment.