Skip to content

fix: prepare to drop allowComposition option #1496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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