Skip to content

Commit

Permalink
breaking: drop $tc and tc (#2017)
Browse files Browse the repository at this point in the history
* breaking: drop `$tc` and `tc`

* docs: add breaking changes for v11

* docs: more tweaks
  • Loading branch information
kazupon authored Nov 16, 2024
1 parent 60902cc commit 3882d02
Show file tree
Hide file tree
Showing 21 changed files with 332 additions and 1,110 deletions.
6 changes: 5 additions & 1 deletion docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'vitepress'
import type { HeadConfig } from 'vitepress'
import { defineConfig } from 'vitepress'

const head: HeadConfig[] = [['link', { rel: 'icon', href: '/vue-i18n-logo.png' }]]

Expand Down Expand Up @@ -206,6 +206,10 @@ function sidebarGuide() {
text: 'Breaking Changes in v10',
link: '/guide/migration/breaking10'
},
{
text: 'Breaking Changes in v11',
link: '/guide/migration/breaking11'
},
{
text: 'New Features in v9',
link: '/guide/migration/features'
Expand Down
257 changes: 0 additions & 257 deletions docs/api/injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,263 +597,6 @@ Overloaded `$rt`. About details, see the [$rt](injection#rt-message) remarks.

Translation message

### $tc(key)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

If this is used in a reactive context, it will re-evaluate once the locale changes.

The input / output is the same as for VueI18n instance. About that details, see [VueI18n#tc](legacy#tc-key).

The value of plural is handled with default `1`.

**See Also**
- [Pluralization](../guide/essentials/pluralization)

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |

#### Returns

Translation message that is pluraled

### $tc(key, locale)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, locale: Locale): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| locale | Locale | A locale, override locale that global scope or local scope |

#### Returns

Translation message that is pluraled

### $tc(key, list)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, list: unknown[]): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| list | unknown[] | A values of list interpolation |

#### Returns

Translation message that is pluraled

### $tc(key, named)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, named: Record<string, unknown>): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| named | Record&lt;string, unknown&gt; | A values of named interpolation |

#### Returns

Translation message that is pluraled

### $tc(key, choice)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, choice: number): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| choice | number | Which plural string to get. 1 returns the first one |

#### Returns

Translation message that is pluraled

### $tc(key, choice, locale)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, choice: number, locale: Locale): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| choice | number | Which plural string to get. 1 returns the first one |
| locale | Locale | A locale, override locale that global scope or local scope |

#### Returns

Translation message that is pluraled

### $tc(key, choice, list)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, choice: number, list: unknown[]): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| choice | number | Which plural string to get. 1 returns the first one |
| list | unknown[] | A values of list interpolation |

#### Returns

Translation message that is pluraled

### $tc(key, choice, named)

:::danger NOTICE
**`$tc` has been deprecated in v10. Use `$t` instead. `$tc` is going to remove in v11.**
:::

Locale message pluralization

**Signature:**
```typescript
$tc(key: Key, choice: number, named: Record<string, unknown>): TranslateResult;
```

:::warning NOTE
Supported for **Legacy API mode only**.
:::

**Details**

Overloaded `$tc`. About details, see the [$tc](injection#tc-key) remarks.

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Key | A target locale message key |
| choice | number | Which plural string to get. 1 returns the first one |
| named | Record&lt;string, unknown&gt; | A values of named interpolation |

#### Returns

Translation message that is pluraled

### $te(key, locale)

Translation message exist
Expand Down
2 changes: 0 additions & 2 deletions docs/guide/advanced/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ For more details of `t`, see the [API Reference](../../api/composition#t-key).

## Pluralization

In the Legacy API mode, the plural form of the message was translated using either `$tc` or the VueI18n instance of `tc` to translate the message.

In the Composition API mode, the plural form of the message is left in syntax as in the Legacy API mode, but is translated using the `t` of the Composer instance:

```vue
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/essentials/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[In *'Scope and Locale Changing’*](scope), Vue I18n has two scope concepts, global scope and local scope.

In general, locale info (e.g. `locale`,`messages`, etc) is set as option of `createI18n` and it sets (install) with `app.use`. To sum up, you use global scope translation functions `$t` and `$tc` to localize them.
In general, locale info (e.g. `locale`,`messages`, etc) is set as option of `createI18n` and it sets (install) with `app.use`. To sum up, you use global scope translation functions `$t` to localize them.

Sometimes it is necessary to localize per component while still managing the resources of the local messages. In this case it can be useful to localize each local scope using i18n component option on the component instead of the global scope.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/essentials/pluralization.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The `apple` has `no apples | one apple | {count} apples` pluralization message,

The number can be accessed within locale messages via predefined named arguments `{count}` and/or `{n}`. You can overwrite those predefined named arguments if necessary.

The following is an example of using `$tc`:
The following is an example of using `$t`:

```html
<p>{{ $t('apple', 10, { count: 10 }) }}</p>
Expand Down
18 changes: 18 additions & 0 deletions docs/guide/migration/breaking11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Breaking Changes in v11

## Deprecate Legacy API mode

### Reason

The Legacy API mode was the API mode compatible with v8 for Vue 2. When v9 was released, the Legacy API was provided to smooth the migration from v8 to v9.

Legacy API mode will be deprecated in v11, as previous vue-i18n releases have already provided the following to support migration to Composition API mode

- Migration from Legacy API mode to Composition API mode: https://vue-i18n.intlify.dev/guide/migration/vue3.html
- Composition API usage: https://vue-i18n.intlify.dev/guide/advanced/composition.html

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.

## Drop `tc` and `$tc` for Legacy API mode

**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
1 change: 0 additions & 1 deletion packages/petite-vue-i18n/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export {
VueI18nOptions,
VueI18nResolveLocaleMessageTranslation,
VueI18nTranslation,
VueI18nTranslationChoice,
WarnHtmlInMessageLevel
} from '../../vue-i18n-core/src/legacy'
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
Expand Down
1 change: 0 additions & 1 deletion packages/petite-vue-i18n/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export {
VueI18nOptions,
VueI18nResolveLocaleMessageTranslation,
VueI18nTranslation,
VueI18nTranslationChoice,
WarnHtmlInMessageLevel
} from '../../vue-i18n-core/src/legacy'
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
Expand Down
Loading

0 comments on commit 3882d02

Please sign in to comment.