Skip to content

Commit

Permalink
fix: prepare to drop 'allowComposition' option (#1496)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon authored Aug 16, 2023
1 parent 1bf6495 commit de5e139
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/guide/migration/vue3.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Developing a Vue application with a mix of Options API styles and Compostion API

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

### About supporting

:::warning NOTICE
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.
:::

### Limitations

:::warning NOTICE
Expand Down
6 changes: 6 additions & 0 deletions packages/vue-i18n-core/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ export function createI18n(options: any = {}, VueI18nLegacy?: any): any {
__DEV__ ? 'vue-i18n' : ''
)

if (__DEV__) {
if (__legacyMode && __allowComposition) {
warn(getWarnMessage(I18nWarnCodes.NOTICE_DROP_ALLOW_COMPOSITION))
}
}

function __getInstance<Instance extends VueI18n | Composer>(
component: ComponentInternalInstance
): Instance | null {
Expand Down
6 changes: 4 additions & 2 deletions packages/vue-i18n-core/src/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const I18nWarnCodes = {
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
NOT_FOUND_PARENT_SCOPE: inc(), // 13
IGNORE_OBJ_FLATTEN: inc() // 14
IGNORE_OBJ_FLATTEN: inc(), // 14
NOTICE_DROP_ALLOW_COMPOSITION: inc() // 15
} as const

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

export function getWarnMessage(
Expand Down

0 comments on commit de5e139

Please sign in to comment.