Skip to content

Commit ec413f2

Browse files
authored
feat: change globalInjection option default value (#974)
* feat: change `globalInjection` option default value * refactor: unit tests
1 parent 6e4e5c4 commit ec413f2

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

docs/guide/advanced/composition.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ Another way to refer a global scope Composer instance is through properties and
311311

312312
You need to specify **`globalInjection: true`** together with `legacy: false` as an option for `createI18n`, because disabled by default.
313313

314+
:::tip NOTE
315+
vue-i18n v9.2-beta.34 or later, `globalInjection` is `true` by default.
316+
:::
317+
314318
This allows Vue I18n to inject the following properties and functions into the components:
315319

316320
- `$i18n`: An object wrapped with the following global scope Composer instance properties

docs/ja/guide/advanced/composition.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ Another way to refer a global scope Composer instance is through properties and
311311

312312
You need to specify **`globalInjection: true`** together with `legacy: false` as an option for `createI18n`, because disabled by default.
313313

314+
:::tip NOTE
315+
vue-i18n v9.2-beta.34 or later, `globalInjection` is `true` by default.
316+
:::
317+
314318
This allows Vue I18n to inject the following properties and functions into the components:
315319

316320
- `$i18n`: An object wrapped with the following global scope Composer instance properties

packages/vue-i18n-core/src/i18n.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export interface I18nAdditionalOptions {
156156
* @VueI18nSee [Implicit with injected properties and functions](../guide/advanced/composition#implicit-with-injected-properties-and-functions)
157157
* @VueI18nSee [ComponentCustomProperties](injection#componentcustomproperties)
158158
*
159-
* @defaultValue `false`
159+
* @defaultValue `true`
160160
*/
161161
globalInjection?: boolean
162162
/**
@@ -482,9 +482,7 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
482482
? options.legacy
483483
: __FEATURE_LEGACY_API__
484484
// prettier-ignore
485-
const __globalInjection = /* #__PURE__*/ !__BRIDGE__
486-
? !!options.globalInjection
487-
: isBoolean(options.globalInjection)
485+
const __globalInjection = isBoolean(options.globalInjection)
488486
? options.globalInjection
489487
: true
490488
// prettier-ignore

packages/vue-i18n-core/test/issues.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ describe('issue #722', () => {
169169

170170
const i18n = createI18n({
171171
legacy: false,
172-
globalInjection: true,
173172
locale: 'en',
174173
messages
175174
})
@@ -245,7 +244,6 @@ describe('issue #722', () => {
245244

246245
const i18n = createI18n({
247246
legacy: false,
248-
globalInjection: true,
249247
locale: 'en',
250248
messages
251249
})
@@ -363,7 +361,6 @@ describe('issue #853', () => {
363361
legacy: false,
364362
locale: 'en',
365363
fallbackLocale: 'en',
366-
globalInjection: true,
367364
warnHtmlMessage: false,
368365
messages: {
369366
en: {

0 commit comments

Comments
 (0)