Skip to content
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

breaking: drop fully preserveDirectiveContent option codes on Legacy API #1827

Merged
merged 1 commit into from
Apr 27, 2024
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
1 change: 0 additions & 1 deletion docs/.ja/guide/advanced/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ Below is the mapping table:
| `sync` | `inheritLocale` |
| `warnHtmlInMessage` | `warnHtmlMessage` |
| `escapeParameterHtml` | `escapeParameter` |
| `preserveDirectiveContent` | N/A |
| `t` | `t` |
| `tc` | `t` |
| `te` | `te` |
Expand Down
1 change: 0 additions & 1 deletion docs/guide/advanced/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ Below is the mapping table:
| `sync` | `inheritLocale` |
| `warnHtmlInMessage` | `warnHtmlMessage` |
| `escapeParameterHtml` | `escapeParameter` |
| `preserveDirectiveContent` | N/A |
| `t` | `t` |
| `tc` | `t` |
| `te` | `te` |
Expand Down
8 changes: 6 additions & 2 deletions docs/guide/migration/breaking.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,18 @@ console.log(VueI18n.availability)

### Remove Custom formatter

**Reason**: Due to hard to provide custom formats in the new compiler and runtime APIs. We are planning to support it in the next major version to support in these APIs. If you would like to use ICU message format, you can use the [@formatjs/vue-intl](https://formatjs.io/docs/vue-intl/)

> [!CAUTION]
> `formatter` option implementation code is be going to fully remove in v10.
> As an alternative, vue-i18n has the [custome message format](../advanced/format.md) as an experimental feature.

**Reason**: Due to hard to provide custom formats in the new compiler and runtime APIs. We are planning to support it in the next major version to support in these APIs. If you would like to use ICU message format, you can use the [@formatjs/vue-intl](https://formatjs.io/docs/vue-intl/)

### Remove `preserveDirectiveContent` option

> [!CAUTION]
> `preserveDirectiveContent` option implementation code is be going to fully remove in v10.
> As an alternative.

The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance.

Vue I18n v8.x:
Expand Down
37 changes: 0 additions & 37 deletions packages/vue-i18n-core/src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,6 @@ export interface VueI18nOptions<
* @defaultValue `false`
*/
formatFallbackMessages?: Options['fallbackFormat']
/**
* @remarks
* Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
*
* @VueI18nSee [Custom Directive](../guide/advanced/directive)
* @VueI18nSee [Remove `preserveDirectiveContent` option](../guide/migration/breaking#remove-preservedirectivecontent-option)
*
* @defaultValue `false`
*
* @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance.
*/
preserveDirectiveContent?: boolean
/**
* @remarks
* Whether to allow the use locale messages of HTML formatting.
Expand Down Expand Up @@ -1015,16 +1003,6 @@ export interface VueI18n<
* @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
*/
escapeParameterHtml: Composition['escapeParameter']
/**
* @remarks
* Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
*
* @VueI18nSee [Custom Directive](../guide/advanced/directive)
* @VueI18nSee [Remove preserveDirectiveContent option](../guide/migration/breaking#remove-preservedirectivecontent-option)
*
* @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance.
*/
preserveDirectiveContent: boolean
/**
* A set of rules for word pluralization
*
Expand Down Expand Up @@ -1332,10 +1310,6 @@ function convertComposerOptions<
const escapeParameter = !!options.escapeParameterHtml
const inheritLocale = isBoolean(options.sync) ? options.sync : true

if (__DEV__ && options.preserveDirectiveContent) {
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
}

let messages = options.messages
if (isPlainObject(options.sharedMessages)) {
const sharedMessages = options.sharedMessages
Expand Down Expand Up @@ -1564,17 +1538,6 @@ export function createVueI18n(options: any = {}): any {
composer.escapeParameter = val
},

// preserveDirectiveContent
get preserveDirectiveContent(): boolean {
__DEV__ &&
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
return true
},
set preserveDirectiveContent(val: boolean) {
__DEV__ &&
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
},

// pluralizationRules
get pluralizationRules(): PluralizationRules {
return composer.pluralRules || {}
Expand Down
12 changes: 5 additions & 7 deletions packages/vue-i18n-core/src/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ const inc = incrementer(code)
export const I18nWarnCodes = {
FALLBACK_TO_ROOT: code, // 8
NOT_SUPPORTED_PRESERVE: inc(), // 9
NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc(), // 10
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
NOT_FOUND_PARENT_SCOPE: inc(), // 13
IGNORE_OBJ_FLATTEN: inc(), // 14
NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 15
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 10
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 11
NOT_FOUND_PARENT_SCOPE: inc(), // 12
IGNORE_OBJ_FLATTEN: inc(), // 13
NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 14
} as const

type I18nWarnCodes = (typeof I18nWarnCodes)[keyof typeof I18nWarnCodes]

export const warnMessages: { [code: number]: string } = {
[I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`,
[I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`,
[I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`,
[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.`,
Expand Down