Skip to content

Commit 3ab1d8e

Browse files
authored
feat!: change $t overloaded signature for Legacy API mode (#1832)
* breaking: change `$t` overloaded signature for Legacy API mode * fix: typo * chore: add node v22
1 parent 4c3434b commit 3ab1d8e

File tree

12 files changed

+276
-473
lines changed

12 files changed

+276
-473
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
strategy:
8484
matrix:
8585
os: [ubuntu-latest, windows-latest, macos-latest]
86-
node: [18.19, 20]
86+
node: [18.19, 20, 22]
8787

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

@@ -144,7 +144,7 @@ jobs:
144144
strategy:
145145
matrix:
146146
os: [ubuntu-latest, windows-latest, macos-latest]
147-
node: [18.19, 20]
147+
node: [18.19, 20, 22]
148148

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

docs/.vitepress/config.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,15 @@ function sidebarGuide() {
195195
collapsible: true,
196196
items: [
197197
{
198-
text: 'Breaking Changes',
198+
text: 'Breaking Changes in v9',
199199
link: '/guide/migration/breaking'
200200
},
201201
{
202-
text: 'New Features',
202+
text: 'Breaking Changes in v10',
203+
link: '/guide/migration/breaking10'
204+
},
205+
{
206+
text: 'New Features in v9',
203207
link: '/guide/migration/features'
204208
},
205209
{

docs/api/injection.md

Lines changed: 34 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ Translation message
9090

9191
### $t(key, locale)
9292

93+
:::danger NOTICE
94+
**This API signature is available in Legacy API mode only and is supported until v9**.
95+
:::
96+
9397
Locale message translation
9498

9599
**Signature:**
@@ -113,6 +117,10 @@ Translation message
113117

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

120+
:::danger NOTICE
121+
**This API signature is available in Legacy API mode only and is supported until v9**.
122+
:::
123+
116124
Locale message translation
117125

118126
**Signature:**
@@ -137,6 +145,10 @@ Translation message
137145

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

148+
:::danger NOTICE
149+
**This API signature is available in Legacy API mode only and is supported until v9**.
150+
:::
151+
140152
Locale message translation
141153

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

160172
Translation message
161173

162-
### $t(key, list)
163-
164-
Locale message translation
165-
166-
**Signature:**
167-
```typescript
168-
$t(key: Path, list: unknown[]): TranslateResult;
169-
```
170-
171-
**Details**
172-
173-
Overloaded `$t`. About details, see the [$t](injection#t-key) remarks.
174-
175-
#### Parameters
176-
| Parameter | Type | Description |
177-
| --- | --- | --- |
178-
| key | Path | A target locale message key |
179-
| list | unknown[] | A values of list interpolation |
180-
181-
#### Returns
182-
183-
Translation message
184-
185-
### $t(key, named)
186-
187-
Locale message translation
188-
189-
**Signature:**
190-
```typescript
191-
$t(key: Path, named: Record<string, unknown>): TranslateResult;
192-
```
193-
194-
**Details**
195-
196-
Overloaded `$t`. About details, see the [$t](injection#t-key) remarks.
197-
198-
#### Parameters
199-
| Parameter | Type | Description |
200-
| --- | --- | --- |
201-
| key | Path | A target locale message key |
202-
| locale | Locale | A locale, override locale that global scope or local scope |
203-
| named | Record&lt;string, unknown&gt; | A values of named interpolation |
204-
205-
#### Returns
206-
207-
Translation message
208-
209-
### $t(key)
210-
211-
Locale message translation
212-
213-
**Signature:**
214-
```typescript
215-
$t(key: Path): string;
216-
```
217-
218-
**Details**
219-
220-
Overloaded `$t`. About details, see the [$t](injection#t-key) remarks.
221-
222-
#### Parameters
223-
| Parameter | Type | Description |
224-
| --- | --- | --- |
225-
| key | Path | A target locale message key |
226-
227-
#### Returns
228-
229-
Translation message
230-
231174
### $t(key, plural)
232175

233176
Locale message translation
234177

235178
**Signature:**
236179
```typescript
237-
$t(key: Path, plural: number): string;
180+
$t(key: Path, plural: number): TranslateResult;
238181
```
239182

240183
:::tip NOTE
241-
Supported for **Composition API mode only**.
184+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
242185
:::
243186

244187
**Details**
@@ -261,11 +204,11 @@ Locale message translation
261204

262205
**Signature:**
263206
```typescript
264-
$t(key: Path, plural: number, options: TranslateOptions): string;
207+
$t(key: Path, plural: number, options: TranslateOptions): TranslateResult;
265208
```
266209

267210
:::tip NOTE
268-
Supported for **Composition API mode only**.
211+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
269212
:::
270213

271214
**Details**
@@ -289,11 +232,11 @@ Locale message translation
289232

290233
**Signature:**
291234
```typescript
292-
$t(key: Path, defaultMsg: string): string;
235+
$t(key: Path, defaultMsg: string): TranslateResult;
293236
```
294237

295238
:::tip NOTE
296-
Supported for **Composition API mode only**.
239+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
297240
:::
298241

299242
**Details**
@@ -316,11 +259,11 @@ Locale message translation
316259

317260
**Signature:**
318261
```typescript
319-
$t(key: Path, defaultMsg: string, options: TranslateOptions): string;
262+
$t(key: Path, defaultMsg: string, options: TranslateOptions): TranslateResult;
320263
```
321264

322265
:::tip NOTE
323-
Supported for **Composition API mode only**.
266+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
324267
:::
325268

326269
**Details**
@@ -344,7 +287,7 @@ Locale message translation
344287

345288
**Signature:**
346289
```typescript
347-
$t(key: Path, list: unknown[]): string;
290+
$t(key: Path, list: unknown[]): TranslateResult;
348291
```
349292

350293
**Details**
@@ -367,11 +310,11 @@ Locale message translation
367310

368311
**Signature:**
369312
```typescript
370-
$t(key: Path, list: unknown[], plural: number): string;
313+
$t(key: Path, list: unknown[], plural: number): TranslateResult;
371314
```
372315

373316
:::tip NOTE
374-
Supported for **Composition API mode only**.
317+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
375318
:::
376319

377320
**Details**
@@ -395,11 +338,11 @@ Locale message translation
395338

396339
**Signature:**
397340
```typescript
398-
$t(key: Path, list: unknown[], defaultMsg: string): string;
341+
$t(key: Path, list: unknown[], defaultMsg: string): TranslateResult;
399342
```
400343

401344
:::tip NOTE
402-
Supported for **Composition API mode only**.
345+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
403346
:::
404347

405348
**Details**
@@ -423,11 +366,11 @@ Locale message translation
423366

424367
**Signature:**
425368
```typescript
426-
$t(key: Path, list: unknown[], options: TranslateOptions): string;
369+
$t(key: Path, list: unknown[], options: TranslateOptions): TranslateResult;
427370
```
428371

429372
:::tip NOTE
430-
Supported for **Composition API mode only**.
373+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
431374
:::
432375

433376
**Details**
@@ -451,7 +394,7 @@ Locale message translation
451394

452395
**Signature:**
453396
```typescript
454-
$t(key: Path, named: NamedValue): string;
397+
$t(key: Path, named: NamedValue): TranslateResult;
455398
```
456399

457400
**Details**
@@ -474,11 +417,11 @@ Locale message translation
474417

475418
**Signature:**
476419
```typescript
477-
$t(key: Path, named: NamedValue, plural: number): string;
420+
$t(key: Path, named: NamedValue, plural: number): TranslateResult;
478421
```
479422

480423
:::tip NOTE
481-
Supported for **Composition API mode only**.
424+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
482425
:::
483426

484427
**Details**
@@ -502,11 +445,11 @@ Locale message translation
502445

503446
**Signature:**
504447
```typescript
505-
$t(key: Path, named: NamedValue, defaultMsg: string): string;
448+
$t(key: Path, named: NamedValue, defaultMsg: string): TranslateResult;
506449
```
507450

508451
:::tip NOTE
509-
Supported for **Composition API mode only**.
452+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
510453
:::
511454

512455
**Details**
@@ -530,11 +473,11 @@ Locale message translation
530473

531474
**Signature:**
532475
```typescript
533-
$t(key: Path, named: NamedValue, options: TranslateOptions): string;
476+
$t(key: Path, named: NamedValue, options: TranslateOptions): TranslateResult;
534477
```
535478

536479
:::tip NOTE
537-
Supported for **Composition API mode only**.
480+
Supported for **Composition API mode only until v9. v10 or later can also be used in Legacy API mode**.
538481
:::
539482

540483
**Details**

docs/guide/migration/breaking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Breaking Changes
1+
# Breaking Changes in v9
22

33
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.
44

0 commit comments

Comments
 (0)