From 2f57ab222a5ecee594ad8a756ce0c71e7b5dbae5 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Wed, 13 Nov 2024 23:19:11 +0900 Subject: [PATCH 1/4] docs: not use deprecated api --- docs/.ja/guide/advanced/function.md | 12 +++---- docs/guide/advanced/function.md | 12 +++---- docs/guide/essentials/pluralization.md | 47 +++++++++++++------------- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/docs/.ja/guide/advanced/function.md b/docs/.ja/guide/advanced/function.md index 87902b412..94af001c4 100644 --- a/docs/.ja/guide/advanced/function.md +++ b/docs/.ja/guide/advanced/function.md @@ -188,12 +188,12 @@ const messages = { Template: ```html -

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

-

{{ $tc('apple', 0) }}

-

{{ $tc('apple', 1) }}

-

{{ $tc('apple', 10, { count: 10 }) }}

+

{{ $t('apple', 0) }}

+

{{ $t('apple', 1) }}

+

{{ $t('apple', 10, { count: 10 }) }}

``` Output is the below: @@ -207,4 +207,4 @@ Output is the below:

10 apples

``` -You need to specify the key that resolves the value specified with `$tc` or `tc`. +You need to specify the key that resolves the value specified with `$t` or `t`. diff --git a/docs/guide/advanced/function.md b/docs/guide/advanced/function.md index 87902b412..94af001c4 100644 --- a/docs/guide/advanced/function.md +++ b/docs/guide/advanced/function.md @@ -188,12 +188,12 @@ const messages = { Template: ```html -

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

-

{{ $tc('apple', 0) }}

-

{{ $tc('apple', 1) }}

-

{{ $tc('apple', 10, { count: 10 }) }}

+

{{ $t('apple', 0) }}

+

{{ $t('apple', 1) }}

+

{{ $t('apple', 10, { count: 10 }) }}

``` Output is the below: @@ -207,4 +207,4 @@ Output is the below:

10 apples

``` -You need to specify the key that resolves the value specified with `$tc` or `tc`. +You need to specify the key that resolves the value specified with `$t` or `t`. diff --git a/docs/guide/essentials/pluralization.md b/docs/guide/essentials/pluralization.md index 12fcaa14d..cc7c2d898 100644 --- a/docs/guide/essentials/pluralization.md +++ b/docs/guide/essentials/pluralization.md @@ -25,34 +25,33 @@ The `car` has `car | cars` pluralization message, while the `apple` has `no appl These plural messages are selected by the logic of the choice rule for each language in the translaton API according to the numeric value you specify at the translation API. -Vue I18n offers some ways to support pluralization. Here we’ll use the `$tc`. +Vue I18n offers some ways to support pluralization. Here we’ll use the `$t`. :::tip NOTE -`$tc` has some overloads. About these overloads, see the [API Reference](../../api/injection#tc-key) +`$t` has some overloads. About these overloads, see the [API Reference](../../api/injection#t-key) ::: :::tip NOTE Some ways to support pluralization are: -- `$tc` (for Legacy API mode) +- injected gloal `$t` - `v-t` custom directive - built-in Translation component (`i18n-t`) - exported `t` from `useI18n` (for Composition API mode) -- injected global `$t` (for Composition API mode) ::: The following is an example of using the translation API. ```html -

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

-

{{ $tc('apple', 0) }}

-

{{ $tc('apple', 1) }}

-

{{ $tc('apple', 10, { count: 10 }) }}

+

{{ $t('apple', 0) }}

+

{{ $t('apple', 1) }}

+

{{ $t('apple', 10, { count: 10 }) }}

``` -In the above example of using the `$tc`, the first argument is the locale messages key and the second argument is a number. The `$tc` returns the choice message as a result. +In the above example of using the `$t`, the first argument is the locale messages key and the second argument is a number. The `$t` returns the choice message as a result. As result the below: @@ -91,12 +90,12 @@ The number can be accessed within locale messages via predefined named arguments The following is an example of using `$tc`: ```html -

{{ $tc('apple', 10, { count: 10 }) }}

-

{{ $tc('apple', 10) }}

+

{{ $t('apple', 10, { count: 10 }) }}

+

{{ $t('apple', 10) }}

-

{{ $tc('banana', 1, { n: 1 }) }}

-

{{ $tc('banana', 1) }}

-

{{ $tc('banana', 100, { n: 'too many' }) }}

+

{{ $t('banana', 1, { n: 1 }) }}

+

{{ $t('banana', 1) }}

+

{{ $t('banana', 100, { n: 'too many' }) }}

``` In the above some examples, the first argument is the locale messages key and the second argument is the numeric value or object. @@ -169,17 +168,17 @@ With the following template: ```html

Car:

-

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

-

{{ $tc('car', 4) }}

-

{{ $tc('car', 12) }}

-

{{ $tc('car', 21) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

+

{{ $t('car', 4) }}

+

{{ $t('car', 12) }}

+

{{ $t('car', 21) }}

Banana:

-

{{ $tc('banana', 0) }}

-

{{ $tc('banana', 4) }}

-

{{ $tc('banana', 11) }}

-

{{ $tc('banana', 31) }}

+

{{ $t('banana', 0) }}

+

{{ $t('banana', 4) }}

+

{{ $t('banana', 11) }}

+

{{ $t('banana', 31) }}

``` As result the below: From baf2b4d38decdeecc74628ad598aaeb229f35f9c Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Wed, 13 Nov 2024 23:55:57 +0900 Subject: [PATCH 2/4] fix: e2e --- examples/legacy/functions/plural.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/legacy/functions/plural.html b/examples/legacy/functions/plural.html index 8fcb5d6d9..16fbe7617 100644 --- a/examples/legacy/functions/plural.html +++ b/examples/legacy/functions/plural.html @@ -9,17 +9,17 @@

Car:

-

{{ $tc('car', 1) }}

-

{{ $tc('car', 2) }}

+

{{ $t('car', 1) }}

+

{{ $t('car', 2) }}

Apple:

-

{{ $tc('apple', 0) }}

-

{{ $tc('apple', 1) }}

-

{{ $tc('apple', 10, { count: 10 }) }}

-

{{ $tc('apple', 10) }}

+

{{ $t('apple', 0) }}

+

{{ $t('apple', 1) }}

+

{{ $t('apple', 10, { count: 10 }) }}

+

{{ $t('apple', 10) }}

Banana:

-

{{ $tc('banana', 1, { n: 1 }) }}

-

{{ $tc('banana', 1) }}

-

{{ $tc('banana', 100, { n: 'too many' }) }}

+

{{ $t('banana', 1, { n: 1 }) }}

+

{{ $t('banana', 1) }}

+

{{ $t('banana', 100, { n: 'too many' }) }}