Skip to content

Commit 959f271

Browse files
authored
feat!: deprecate v-t custom directive (#2045)
* feat!: deprecate `v-t` custom directive * fix: e2e
1 parent 404831b commit 959f271

File tree

13 files changed

+93
-19
lines changed

13 files changed

+93
-19
lines changed

docs/.vitepress/config.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ function sidebarGuide() {
195195
collapsible: true,
196196
items: [
197197
{
198-
text: 'Breaking Changes in v9',
199-
link: '/guide/migration/breaking'
198+
text: 'Breaking Changes in v11',
199+
link: '/guide/migration/breaking11'
200200
},
201201
{
202202
text: 'Breaking Changes in v10',
203203
link: '/guide/migration/breaking10'
204204
},
205205
{
206-
text: 'Breaking Changes in v11',
207-
link: '/guide/migration/breaking11'
206+
text: 'Breaking Changes in v9',
207+
link: '/guide/migration/breaking'
208208
},
209209
{
210210
text: 'New Features in v9',

docs/guide/advanced/directive.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Custom Directive
22

3+
:::danger NOTE
4+
`v-t` will be deprecated at v11, and will be dropped at v12. This section is for those who are still using v10.
5+
:::
6+
37
You can translate not only with `$t`, but also with the `v-t` custom directive.
48

59
## String syntax

docs/guide/migration/breaking11.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Breaking Changes in v11
22

3+
:::warning NOTICE
4+
Vue I18n v11 is still beta
5+
:::
6+
37
## Deprecate Legacy API mode
48

59
### Reason
@@ -13,6 +17,21 @@ Legacy API mode will be deprecated in v11, as previous vue-i18n releases have al
1317

1418
For compatibility, Legacy API mode still works in v11, but will be removed entirely in v12, so Legacy API mode will not work after that version.
1519

20+
## Deprecate Custom Directive `v-t`
21+
22+
### Reason
23+
24+
The advantage of `v-t` was that it could optimize performance using the vue compiler transform and the pre-translation of `vue-i18n-extension`.
25+
26+
This feature was supported from Vue 2.
27+
About details see the blog article: https://medium.com/@kazu_pon/performance-optimization-of-vue-i18n-83099eb45c2d
28+
29+
In Vue 3, due to the Composition API, the pre-translation of `vue-i18n-extension` is now limited only for global scope.
30+
31+
In addition, Vue 3 Virtual DOM optimization has been introduced, and the optimization provided by `vue-i18n-extension` is no longer very effective. We need to require settings for SSR, the benefits of using `v-t` have disappeared. And DX of templates using `v-t` is not good. Custom directives do not work with key completion in editors (e.g. vscode).
32+
33+
For compatibility, `v-t` mode still works in v11, but will be removed entirely in v12, so `v-t` will not work after that version.
34+
1635
## Drop `tc` and `$tc` for Legacy API mode
1736

1837
**Reason**: These APIs had already deprecated in warning about being dropped in v11. docs says, https://vue-i18n.intlify.dev/guide/migration/breaking10.html#deprecate-tc-and-tc-for-legacy-api-mode

e2e/fallback/basic.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

e2e/fallback/default-format.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { getText, url } from '../helper'
55
beforeAll(async () => {
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
8-
warnings.push(msg.text())
8+
const text = msg.text()
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
13+
warnings.push(msg.text())
14+
}
915
}
1016
})
1117
await page.goto(url(`/examples/${pattern}/fallback/default-format.html`))

e2e/fallback/format.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

e2e/fallback/option.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

e2e/fallback/suppress.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

e2e/missing/handler.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

e2e/missing/option.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { getText, url } from '../helper'
66
page.on('console', msg => {
77
if (msg.type() === 'warning') {
88
const text = msg.text()
9-
if (!text.match(/^\[intlify\] Legacy API mode has been/)) {
9+
if (
10+
!text.match(/^\[intlify\] Legacy API mode has been/) &&
11+
!text.match(/^\[intlify\] 'v-t' has been deprecated in v11/)
12+
) {
1013
warnings.push(msg.text())
1114
}
1215
}

0 commit comments

Comments
 (0)