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

feat!: change $t overloaded signature for Legacy API mode #1832

Merged
merged 3 commits into from
Apr 30, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [18.19, 20]
node: [18.19, 20, 22]

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [18.19, 20]
node: [18.19, 20, 22]

runs-on: ${{ matrix.os }}

Expand Down
8 changes: 6 additions & 2 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,15 @@ function sidebarGuide() {
collapsible: true,
items: [
{
text: 'Breaking Changes',
text: 'Breaking Changes in v9',
link: '/guide/migration/breaking'
},
{
text: 'New Features',
text: 'Breaking Changes in v10',
link: '/guide/migration/breaking10'
},
{
text: 'New Features in v9',
link: '/guide/migration/features'
},
{
Expand Down
125 changes: 34 additions & 91 deletions docs/api/injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Translation message

### $t(key, locale)

:::danger NOTICE
**This API signature is available in Legacy API mode only and is supported until v9**.
:::

Locale message translation

**Signature:**
Expand All @@ -113,6 +117,10 @@ Translation message

### $t(key, locale, list)

:::danger NOTICE
**This API signature is available in Legacy API mode only and is supported until v9**.
:::

Locale message translation

**Signature:**
Expand All @@ -137,6 +145,10 @@ Translation message

### $t(key, locale, named)

:::danger NOTICE
**This API signature is available in Legacy API mode only and is supported until v9**.
:::

Locale message translation

**Signature:**
Expand All @@ -159,86 +171,17 @@ Overloaded `$t`. About details, see the [$t](injection#t-key) remarks.

Translation message

### $t(key, list)

Locale message translation

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

**Details**

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

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

#### Returns

Translation message

### $t(key, named)

Locale message translation

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

**Details**

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

#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| key | Path | A target locale message key |
| locale | Locale | A locale, override locale that global scope or local scope |
| named | Record&lt;string, unknown&gt; | A values of named interpolation |

#### Returns

Translation message

### $t(key)

Locale message translation

**Signature:**
```typescript
$t(key: Path): string;
```

**Details**

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

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

#### Returns

Translation message

### $t(key, plural)

Locale message translation

**Signature:**
```typescript
$t(key: Path, plural: number): string;
$t(key: Path, plural: number): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -261,11 +204,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, plural: number, options: TranslateOptions): string;
$t(key: Path, plural: number, options: TranslateOptions): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -289,11 +232,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, defaultMsg: string): string;
$t(key: Path, defaultMsg: string): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -316,11 +259,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, defaultMsg: string, options: TranslateOptions): string;
$t(key: Path, defaultMsg: string, options: TranslateOptions): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -344,7 +287,7 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, list: unknown[]): string;
$t(key: Path, list: unknown[]): TranslateResult;
```

**Details**
Expand All @@ -367,11 +310,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, list: unknown[], plural: number): string;
$t(key: Path, list: unknown[], plural: number): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -395,11 +338,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, list: unknown[], defaultMsg: string): string;
$t(key: Path, list: unknown[], defaultMsg: string): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -423,11 +366,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, list: unknown[], options: TranslateOptions): string;
$t(key: Path, list: unknown[], options: TranslateOptions): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -451,7 +394,7 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, named: NamedValue): string;
$t(key: Path, named: NamedValue): TranslateResult;
```

**Details**
Expand All @@ -474,11 +417,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, named: NamedValue, plural: number): string;
$t(key: Path, named: NamedValue, plural: number): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -502,11 +445,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, named: NamedValue, defaultMsg: string): string;
$t(key: Path, named: NamedValue, defaultMsg: string): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand All @@ -530,11 +473,11 @@ Locale message translation

**Signature:**
```typescript
$t(key: Path, named: NamedValue, options: TranslateOptions): string;
$t(key: Path, named: NamedValue, options: TranslateOptions): TranslateResult;
```

:::tip NOTE
Supported for **Composition API mode only**.
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
:::

**Details**
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/migration/breaking.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Breaking Changes
# Breaking Changes in v9

Most of the APIs offered in Vue I18n v9 (for Vue 3) strive to maintain compatibility, to ease the pain of migration from v8 (for Vue 2). But there are still a few breaking changes that you might encounter while migrating your application. This guide is how to adapt your application to make it work with Vue I18n v9.

Expand Down
Loading