Skip to content

Commit de5e139

Browse files
authored
fix: prepare to drop 'allowComposition' option (#1496)
1 parent 1bf6495 commit de5e139

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

docs/guide/migration/vue3.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Developing a Vue application with a mix of Options API styles and Compostion API
1414

1515
From Vue I18n v9.2, the Legacy API mode can also be used with Composition API mode.
1616

17+
### About supporting
18+
19+
:::warning NOTICE
20+
This migration support will be removed in the next major version v10. If your Vue 3 application project has not yet been migrated, please migrate it to v9 and then upgrade to v10.
21+
:::
22+
1723
### Limitations
1824

1925
:::warning NOTICE

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,12 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
552552
__DEV__ ? 'vue-i18n' : ''
553553
)
554554

555+
if (__DEV__) {
556+
if (__legacyMode && __allowComposition) {
557+
warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION))
558+
}
559+
}
560+
555561
function __getInstance<Instance extends VueI18n | Composer>(
556562
component: ComponentInternalInstance
557563
): Instance | null {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const I18nWarnCodes = {
1212
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
1313
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
1414
NOT_FOUND_PARENT_SCOPE: inc(), // 13
15-
IGNORE_OBJ_FLATTEN: inc() // 14
15+
IGNORE_OBJ_FLATTEN: inc(), // 14
16+
NOTICE_DROP_ALLOW_COMPOSITION: inc() // 15
1617
} as const
1718

1819
type I18nWarnCodes = (typeof I18nWarnCodes)[keyof typeof I18nWarnCodes]
@@ -25,7 +26,8 @@ export const warnMessages: { [code: number]: string } = {
2526
[I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`,
2627
[I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`,
2728
[I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`,
28-
[I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`
29+
[I18nWarnCodes.IGNORE_OBJ_FLATTEN]: `Ignore object flatten: '{key}' key has an string value`,
30+
[I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION]: `'allowComposition' option will be dropped in the next major version. For more information, please see 👉 https://tinyurl.com/2p97mcze`
2931
}
3032

3133
export function getWarnMessage(

0 commit comments

Comments
 (0)