@depup/i18next 25.10.4-depup.0 → 25.10.9-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/changes.json +1 -1
- package/dist/esm/package.json +1 -1
- package/index.d.ts +22 -1
- package/jsr.json +1 -1
- package/package.json +4 -4
- package/typescript/t.d.ts +51 -19
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/i18next
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [i18next](https://www.npmjs.com/package/i18next) @ 25.10.
|
|
17
|
-
| Processed | 2026-03-
|
|
16
|
+
| Original | [i18next](https://www.npmjs.com/package/i18next) @ 25.10.9 |
|
|
17
|
+
| Processed | 2026-03-24 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"25.10.
|
|
1
|
+
{"type":"module","version":"25.10.9"}
|
package/index.d.ts
CHANGED
|
@@ -11,8 +11,15 @@ import type {
|
|
|
11
11
|
ResourceKey,
|
|
12
12
|
ResourceLanguage,
|
|
13
13
|
TOptions,
|
|
14
|
+
TypeOptions,
|
|
14
15
|
} from './typescript/options.js';
|
|
15
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
KeyPrefix,
|
|
18
|
+
KeyPrefixSelector,
|
|
19
|
+
TFunction,
|
|
20
|
+
KeyFromSelectorFn,
|
|
21
|
+
SelectorKey,
|
|
22
|
+
} from './typescript/t.js';
|
|
16
23
|
|
|
17
24
|
export interface WithT<Ns extends Namespace = DefaultNamespace> {
|
|
18
25
|
// Expose parameterized t in the i18next interface hierarchy
|
|
@@ -288,6 +295,18 @@ export interface i18n extends CustomInstanceExtensions {
|
|
|
288
295
|
*
|
|
289
296
|
* Accepts optional keyPrefix that will be automatically applied to returned t function.
|
|
290
297
|
*/
|
|
298
|
+
getFixedT<
|
|
299
|
+
Ns extends Namespace | null,
|
|
300
|
+
const TKPrefixFn extends TypeOptions['enableSelector'] extends true | 'optimize'
|
|
301
|
+
? KeyPrefixSelector<ActualNs>
|
|
302
|
+
: never,
|
|
303
|
+
ActualNs extends Namespace = Ns extends null ? DefaultNamespace : Ns,
|
|
304
|
+
>(
|
|
305
|
+
lng: string | readonly string[] | null,
|
|
306
|
+
ns: Ns,
|
|
307
|
+
keyPrefix: TKPrefixFn,
|
|
308
|
+
): TFunction<ActualNs, TKPrefixFn>;
|
|
309
|
+
|
|
291
310
|
getFixedT<
|
|
292
311
|
Ns extends Namespace | null = DefaultNamespace,
|
|
293
312
|
TKPrefix extends KeyPrefix<ActualNs> = undefined,
|
|
@@ -562,6 +581,8 @@ export type {
|
|
|
562
581
|
TFunctionReturn,
|
|
563
582
|
TFunctionDetailedResult,
|
|
564
583
|
KeyPrefix,
|
|
584
|
+
KeyPrefixSelector,
|
|
585
|
+
NsResource,
|
|
565
586
|
InterpolationMap,
|
|
566
587
|
SelectorKey,
|
|
567
588
|
} from './typescript/t.js';
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/i18next",
|
|
3
|
-
"version": "25.10.
|
|
3
|
+
"version": "25.10.9-depup.0",
|
|
4
4
|
"description": "i18next internationalization framework (with updated dependencies)",
|
|
5
5
|
"main": "./dist/cjs/i18next.js",
|
|
6
6
|
"module": "./dist/esm/i18next.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@babel/runtime": "^7.29.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"typescript": "^5"
|
|
60
|
+
"typescript": "^5 || ^6"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"typescript": {
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
"changes": {},
|
|
133
133
|
"depsUpdated": 0,
|
|
134
134
|
"originalPackage": "i18next",
|
|
135
|
-
"originalVersion": "25.10.
|
|
136
|
-
"processedAt": "2026-03-
|
|
135
|
+
"originalVersion": "25.10.9",
|
|
136
|
+
"processedAt": "2026-03-24T12:26:15.798Z",
|
|
137
137
|
"smokeTest": "passed"
|
|
138
138
|
}
|
|
139
139
|
}
|
package/typescript/t.d.ts
CHANGED
|
@@ -464,6 +464,31 @@ export interface TFunction<
|
|
|
464
464
|
|
|
465
465
|
export type KeyPrefix<Ns extends Namespace> = ResourceKeys<true>[$FirstNamespace<Ns>] | undefined;
|
|
466
466
|
|
|
467
|
+
/** The raw (unfiltered) resource object for a given namespace. */
|
|
468
|
+
export type NsResource<Ns extends Namespace> = Ns extends readonly [keyof Resources, any, ...any]
|
|
469
|
+
? Resources[Ns[0]] & PickNamespaces<Resources, Ns[number]>
|
|
470
|
+
: Resources[$FirstNamespace<Ns>];
|
|
471
|
+
|
|
472
|
+
/** A selector function that can be used as `keyPrefix` to scope `t()` to a sub-tree of the resource. */
|
|
473
|
+
export type KeyPrefixSelector<Ns extends Namespace> = (src: NsResource<Ns>) => object;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* The type of a selector function accepted by `t()` for a given namespace and optional key prefix.
|
|
477
|
+
* Use this instead of `Parameters<TFunction<Ns>>[0]` for a stable, readable type.
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```ts
|
|
481
|
+
* import type { SelectorParam } from 'i18next';
|
|
482
|
+
*
|
|
483
|
+
* interface CmpProps {
|
|
484
|
+
* i18nKey: SelectorParam<'myNamespace'>;
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
export type SelectorParam<Ns extends Namespace = DefaultNamespace, KPrefix = undefined> = (
|
|
489
|
+
src: Select<GetSource<Ns, KPrefix>, undefined>,
|
|
490
|
+
) => string;
|
|
491
|
+
|
|
467
492
|
/// ////////////// ///
|
|
468
493
|
/// ↆ selector ↆ ///
|
|
469
494
|
/// ////////////// ///
|
|
@@ -506,6 +531,16 @@ type DeepUnwrapPlural<T> =
|
|
|
506
531
|
type NsArg<Ns extends Namespace> = Ns[number] | readonly Ns[number][];
|
|
507
532
|
|
|
508
533
|
interface TFunctionSelector<Ns extends Namespace, KPrefix, Source> extends Branded<Ns> {
|
|
534
|
+
// ── Pre-computed key(s) from keyFromSelector ────────────────────────────────
|
|
535
|
+
// Accepts a branded `SelectorKey` (or array of them) produced by `keyFromSelector`.
|
|
536
|
+
// Return-type precision is traded for the flexibility of decoupled key creation.
|
|
537
|
+
// Placed first so that the more general selector overloads (below) are last —
|
|
538
|
+
// TypeScript's `Parameters<>` utility resolves against the last call signature.
|
|
539
|
+
<const Opts extends SelectorOptions<Ns[number]> = SelectorOptions<Ns[number]>>(
|
|
540
|
+
key: SelectorKey | SelectorKey[],
|
|
541
|
+
...args: [options?: Opts & $Dictionary]
|
|
542
|
+
): DefaultTReturn<Opts>;
|
|
543
|
+
|
|
509
544
|
// ── Selector(s) with explicit `ns` ───────────────────────────────────────────
|
|
510
545
|
<
|
|
511
546
|
Target extends ConstrainTarget<Opts>,
|
|
@@ -585,14 +620,6 @@ interface TFunctionSelector<Ns extends Namespace, KPrefix, Source> extends Brand
|
|
|
585
620
|
? [options: Opts & { count: number } & InterpolationMap<DeepUnwrapPlural<ReturnType<Fn>>>]
|
|
586
621
|
: [options?: Opts & InterpolationMap<ReturnType<Fn>>]
|
|
587
622
|
): SelectorReturn<ReturnType<Fn>, Opts>;
|
|
588
|
-
|
|
589
|
-
// ── Pre-computed key(s) from keyFromSelector ────────────────────────────────
|
|
590
|
-
// Accepts a branded `SelectorKey` (or array of them) produced by `keyFromSelector`.
|
|
591
|
-
// Return-type precision is traded for the flexibility of decoupled key creation.
|
|
592
|
-
<const Opts extends SelectorOptions<Ns[number]> = SelectorOptions<Ns[number]>>(
|
|
593
|
-
key: SelectorKey | SelectorKey[],
|
|
594
|
-
...args: [options?: Opts & $Dictionary]
|
|
595
|
-
): DefaultTReturn<Opts>;
|
|
596
623
|
}
|
|
597
624
|
|
|
598
625
|
interface SelectorOptions<Ns = Namespace>
|
|
@@ -644,17 +671,22 @@ type PickNamespaces<T, K extends keyof any> = {
|
|
|
644
671
|
[P in K as P extends keyof T ? P : never]: T[P & keyof T];
|
|
645
672
|
};
|
|
646
673
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
:
|
|
656
|
-
|
|
657
|
-
|
|
674
|
+
/** Extracts the sub-tree returned by a selector function used as keyPrefix. */
|
|
675
|
+
type SelectorReturnSource<KPrefix, Fallback> = KPrefix extends (...args: any[]) => infer R
|
|
676
|
+
? R extends object
|
|
677
|
+
? R
|
|
678
|
+
: Fallback
|
|
679
|
+
: Fallback;
|
|
680
|
+
|
|
681
|
+
type GetSource<Ns extends Namespace, KPrefix, Res = NsResource<Ns>> = KPrefix extends (
|
|
682
|
+
...args: any[]
|
|
683
|
+
) => any
|
|
684
|
+
? SelectorReturnSource<KPrefix, Res>
|
|
685
|
+
: KPrefix extends keyof Res
|
|
686
|
+
? Res[KPrefix]
|
|
687
|
+
: undefined extends KPrefix
|
|
688
|
+
? Res
|
|
689
|
+
: ApplyKeyPrefix<[Res], KPrefix>;
|
|
658
690
|
|
|
659
691
|
type Select<T, Context> = $IsResourcesDefined extends false
|
|
660
692
|
? $Turtles
|