Skip to content

Commit f2c31d4

Browse files
authored
breaking: drop fully preserveDirectiveContent option codes on Legacy API (#1827)
1 parent b7392ee commit f2c31d4

File tree

5 files changed

+11
-48
lines changed

5 files changed

+11
-48
lines changed

docs/.ja/guide/advanced/composition.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ Below is the mapping table:
516516
| `sync` | `inheritLocale` |
517517
| `warnHtmlInMessage` | `warnHtmlMessage` |
518518
| `escapeParameterHtml` | `escapeParameter` |
519-
| `preserveDirectiveContent` | N/A |
520519
| `t` | `t` |
521520
| `tc` | `t` |
522521
| `te` | `te` |

docs/guide/advanced/composition.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ Below is the mapping table:
485485
| `sync` | `inheritLocale` |
486486
| `warnHtmlInMessage` | `warnHtmlMessage` |
487487
| `escapeParameterHtml` | `escapeParameter` |
488-
| `preserveDirectiveContent` | N/A |
489488
| `t` | `t` |
490489
| `tc` | `t` |
491490
| `te` | `te` |

docs/guide/migration/breaking.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,18 @@ console.log(VueI18n.availability)
304304

305305
### Remove Custom formatter
306306

307-
**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/)
308-
309307
> [!CAUTION]
310308
> `formatter` option implementation code is be going to fully remove in v10.
311309
> As an alternative, vue-i18n has the [custome message format](../advanced/format.md) as an experimental feature.
312310
311+
**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/)
312+
313313
### Remove `preserveDirectiveContent` option
314314

315+
> [!CAUTION]
316+
> `preserveDirectiveContent` option implementation code is be going to fully remove in v10.
317+
> As an alternative.
318+
315319
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.
316320

317321
Vue I18n v8.x:

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,6 @@ export interface VueI18nOptions<
233233
* @defaultValue `false`
234234
*/
235235
formatFallbackMessages?: Options['fallbackFormat']
236-
/**
237-
* @remarks
238-
* Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
239-
*
240-
* @VueI18nSee [Custom Directive](../guide/advanced/directive)
241-
* @VueI18nSee [Remove `preserveDirectiveContent` option](../guide/migration/breaking#remove-preservedirectivecontent-option)
242-
*
243-
* @defaultValue `false`
244-
*
245-
* @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.
246-
*/
247-
preserveDirectiveContent?: boolean
248236
/**
249237
* @remarks
250238
* Whether to allow the use locale messages of HTML formatting.
@@ -1015,16 +1003,6 @@ export interface VueI18n<
10151003
* @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
10161004
*/
10171005
escapeParameterHtml: Composition['escapeParameter']
1018-
/**
1019-
* @remarks
1020-
* Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
1021-
*
1022-
* @VueI18nSee [Custom Directive](../guide/advanced/directive)
1023-
* @VueI18nSee [Remove preserveDirectiveContent option](../guide/migration/breaking#remove-preservedirectivecontent-option)
1024-
*
1025-
* @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.
1026-
*/
1027-
preserveDirectiveContent: boolean
10281006
/**
10291007
* A set of rules for word pluralization
10301008
*
@@ -1332,10 +1310,6 @@ function convertComposerOptions<
13321310
const escapeParameter = !!options.escapeParameterHtml
13331311
const inheritLocale = isBoolean(options.sync) ? options.sync : true
13341312

1335-
if (__DEV__ && options.preserveDirectiveContent) {
1336-
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
1337-
}
1338-
13391313
let messages = options.messages
13401314
if (isPlainObject(options.sharedMessages)) {
13411315
const sharedMessages = options.sharedMessages
@@ -1564,17 +1538,6 @@ export function createVueI18n(options: any = {}): any {
15641538
composer.escapeParameter = val
15651539
},
15661540

1567-
// preserveDirectiveContent
1568-
get preserveDirectiveContent(): boolean {
1569-
__DEV__ &&
1570-
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
1571-
return true
1572-
},
1573-
set preserveDirectiveContent(val: boolean) {
1574-
__DEV__ &&
1575-
warn(getWarnMessage(I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE))
1576-
},
1577-
15781541
// pluralizationRules
15791542
get pluralizationRules(): PluralizationRules {
15801543
return composer.pluralRules || {}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ const inc = incrementer(code)
77
export const I18nWarnCodes = {
88
FALLBACK_TO_ROOT: code, // 8
99
NOT_SUPPORTED_PRESERVE: inc(), // 9
10-
NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc(), // 10
11-
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
12-
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
13-
NOT_FOUND_PARENT_SCOPE: inc(), // 13
14-
IGNORE_OBJ_FLATTEN: inc(), // 14
15-
NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 15
10+
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 10
11+
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 11
12+
NOT_FOUND_PARENT_SCOPE: inc(), // 12
13+
IGNORE_OBJ_FLATTEN: inc(), // 13
14+
NOTICE_DROP_TRANSLATE_EXIST_COMPATIBLE_FLAG: inc() // 14
1615
} as const
1716

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

2019
export const warnMessages: { [code: number]: string } = {
2120
[I18nWarnCodes.FALLBACK_TO_ROOT]: `Fall back to {type} '{key}' with root locale.`,
2221
[I18nWarnCodes.NOT_SUPPORTED_PRESERVE]: `Not supported 'preserve'.`,
23-
[I18nWarnCodes.NOT_SUPPORTED_PRESERVE_DIRECTIVE]: `Not supported 'preserveDirectiveContent'.`,
2422
[I18nWarnCodes.NOT_SUPPORTED_GET_CHOICE_INDEX]: `Not supported 'getChoiceIndex'.`,
2523
[I18nWarnCodes.COMPONENT_NAME_LEGACY_COMPATIBLE]: `Component name legacy compatible: '{name}' -> 'i18n'`,
2624
[I18nWarnCodes.NOT_FOUND_PARENT_SCOPE]: `Not found parent scope. use the global scope.`,

0 commit comments

Comments
 (0)