@gtkx/i18n 0.0.1

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/src/types.ts ADDED
@@ -0,0 +1,1081 @@
1
+ import type {
2
+ Callback,
3
+ FlatNamespace,
4
+ i18n as I18n,
5
+ InitOptions,
6
+ InterpolationMap,
7
+ KeyPrefix,
8
+ Namespace,
9
+ TFunctionDetailedResult,
10
+ TOptions,
11
+ TFunction as UpstreamTFunction,
12
+ } from "i18next";
13
+ import type * as React from "react";
14
+ import type {
15
+ FallbackNs,
16
+ IcuTrans as upstreamIcuTrans,
17
+ IcuTransProps as UpstreamIcuTransProps,
18
+ IcuTransWithoutContext as upstreamIcuTransWithoutContext,
19
+ IcuTransWithoutContextProps as UpstreamIcuTransWithoutContextProps,
20
+ Trans as upstreamTrans,
21
+ Translation as upstreamTranslation,
22
+ TranslationProps as UpstreamTranslationProps,
23
+ TransProps as UpstreamTransProps,
24
+ TransWithoutContext as upstreamTransWithoutContext,
25
+ useTranslation as upstreamUseTranslation,
26
+ UseTranslationResponse as UpstreamUseTranslationResponse,
27
+ WithTranslation as UpstreamWithTranslation,
28
+ withTranslation as upstreamWithTranslation,
29
+ UseTranslationOptions,
30
+ WithTranslationProps,
31
+ } from "react-i18next";
32
+ import type { TranslationRegistry } from "./index.js";
33
+
34
+ /** A translatable key emitted by GTKX code generation. */
35
+ type RegistryKey = Extract<keyof TranslationRegistry, string>;
36
+ /** The generated metadata associated with a translation key. */
37
+ type RegistryEntry<Key extends RegistryKey> = TranslationRegistry[Key];
38
+ /** Whether code generation found no translation keys. */
39
+ type IsRegistryEmpty = [RegistryKey] extends [never] ? true : false;
40
+
41
+ /** The generated translation entries within a key prefix. */
42
+ type ScopedRegistry<KPrefix extends string | undefined> = KPrefix extends "" | undefined
43
+ ? TranslationRegistry
44
+ : KPrefix extends string
45
+ ? {
46
+ [Key in RegistryKey as Key extends `${KPrefix}.${infer LocalKey}` ? LocalKey : never]:
47
+ RegistryEntry<Key>;
48
+ }
49
+ : TranslationRegistry;
50
+
51
+ /** A translation key accepted for a key prefix. */
52
+ type CallKey<KPrefix extends string | undefined> = Extract<keyof ScopedRegistry<KPrefix>, string>;
53
+
54
+ /** The generated metadata for a prefixed translation key. */
55
+ type ScopedRegistryEntry<
56
+ Key extends CallKey<KPrefix>,
57
+ KPrefix extends string | undefined,
58
+ > = ScopedRegistry<KPrefix>[Key];
59
+
60
+ /** The effective key prefix after i18next normalization. */
61
+ type NormalizedKeyPrefix<KPrefix> = KPrefix extends ""
62
+ ? undefined
63
+ : KPrefix extends string
64
+ ? KPrefix
65
+ : undefined;
66
+
67
+ /** The source translation text recorded for an entry. */
68
+ type EntryValue<Entry> = Entry extends { value: infer Value extends string } ? Value : never;
69
+
70
+ /** The context option required by a generated entry. */
71
+ type ContextOptions<Entry> = Entry extends { context: infer Context extends string }
72
+ ? { context: Context }
73
+ : { context?: never };
74
+
75
+ /** The count option accepted by a generated entry. */
76
+ type CountOptions<Entry> = Entry extends { kind: "plural" | "pluralDefaults" }
77
+ ? { count: number; ordinal?: never }
78
+ : { count?: never; ordinal?: never };
79
+
80
+ /** The interpolation variables required by a generated entry. */
81
+ type InterpolationOptions<Entry> = Entry extends { interpolated: true }
82
+ ? InterpolationMap<EntryValue<Entry>> | { replace: InterpolationMap<EntryValue<Entry>> }
83
+ : Record<never, never>;
84
+
85
+ /** An i18next plural fallback property. */
86
+ type PluralDefaultKey =
87
+ | "defaultValue_few" |
88
+ "defaultValue_many" |
89
+ "defaultValue_one" |
90
+ "defaultValue_ordinal_few" |
91
+ "defaultValue_ordinal_many" |
92
+ "defaultValue_ordinal_one" |
93
+ "defaultValue_ordinal_other" |
94
+ "defaultValue_ordinal_two" |
95
+ "defaultValue_other" |
96
+ "defaultValue_two" |
97
+ "defaultValue_zero";
98
+
99
+ /** Plural fallback properties excluded from a basic lookup. */
100
+ type PluralDefaultExclusions = Partial<Record<PluralDefaultKey, never>>;
101
+
102
+ /** Common options accepted for a generated translation entry. */
103
+ type BaseEntryOptions<Entry> = Entry extends { value: string }
104
+ ? Omit<
105
+ TOptions,
106
+ "context" | "count" | "defaultValue" | "keyPrefix" | "ordinal" | "replace"
107
+ > &
108
+ InterpolationOptions<Entry> &
109
+ ContextOptions<Entry> &
110
+ CountOptions<Entry> & {
111
+ keyPrefix?: never;
112
+ }
113
+ : never;
114
+
115
+ /** Options for a lookup without an inline default value. */
116
+ type EntryOptions<Entry> = BaseEntryOptions<Entry> & PluralDefaultExclusions & {
117
+ /** Prevents an ungenerated default value from bypassing strict lookup types. */
118
+ defaultValue?: never;
119
+ };
120
+
121
+ /** Options for a lookup with an inline default value. */
122
+ type DefaultEntryOptions<Entry, DefaultValue extends string> = BaseEntryOptions<Entry> &
123
+ PluralDefaultExclusions & {
124
+ /** The generated inline fallback translation. */
125
+ defaultValue: DefaultValue;
126
+ };
127
+
128
+ /** Options for a plural lookup with an `other` fallback. */
129
+ type PluralOtherEntryOptions<Entry, DefaultValue extends string> = BaseEntryOptions<Entry> &
130
+ Omit<PluralDefaultExclusions, "defaultValue_other"> & {
131
+ /** Prevents the singular default property in an `other`-only lookup. */
132
+ defaultValue?: never;
133
+ } &
134
+ Record<"defaultValue_other", DefaultValue>;
135
+
136
+ /** Explicit `one` and `other` plural fallback values. */
137
+ type SpecificPluralDefaults<DefaultValueOne extends string, DefaultValueOther extends string> = {
138
+ /** Prevents a general fallback when explicit plural forms are supplied. */
139
+ defaultValue?: never;
140
+ } &
141
+ Record<"defaultValue_one", DefaultValueOne> &
142
+ Record<"defaultValue_other", DefaultValueOther>;
143
+
144
+ /** A singular general fallback paired with an `other` plural fallback. */
145
+ type GeneralSingularDefaults<DefaultValueOne extends string, DefaultValueOther extends string> = {
146
+ /** The singular generated fallback translation. */
147
+ defaultValue: DefaultValueOne;
148
+ } &
149
+ Partial<Record<"defaultValue_one", never>> &
150
+ Record<"defaultValue_other", DefaultValueOther>;
151
+
152
+ /** A plural general fallback paired with a `one` plural fallback. */
153
+ type GeneralPluralDefaults<DefaultValueOne extends string, DefaultValueOther extends string> = {
154
+ /** The plural generated fallback translation. */
155
+ defaultValue: DefaultValueOther;
156
+ } &
157
+ Record<"defaultValue_one", DefaultValueOne> &
158
+ Partial<Record<"defaultValue_other", never>>;
159
+
160
+ /** A generated singular fallback whose plural fallback is the key. */
161
+ type SingularOnlyDefault<DefaultValueOne extends string> = {
162
+ /** Prevents a general fallback for key-backed plurals. */
163
+ defaultValue?: never;
164
+ } &
165
+ Record<"defaultValue_one", DefaultValueOne> &
166
+ Partial<Record<"defaultValue_other", never>>;
167
+
168
+ /** A generated plural fallback whose singular fallback is the key. */
169
+ type PluralOnlyDefault<DefaultValueOther extends string> = {
170
+ /** Prevents a general fallback for key-backed singulars. */
171
+ defaultValue?: never;
172
+ } &
173
+ Partial<Record<"defaultValue_one", never>> &
174
+ Record<"defaultValue_other", DefaultValueOther>;
175
+
176
+ /** Options matching the generated singular and plural fallback values. */
177
+ type PluralDefaultsEntryOptions<
178
+ Entry,
179
+ Key extends string,
180
+ DefaultValueOne extends string,
181
+ DefaultValueOther extends string,
182
+ > = BaseEntryOptions<Entry> &
183
+ Omit<PluralDefaultExclusions, "defaultValue_one" | "defaultValue_other"> &
184
+ (
185
+ SpecificPluralDefaults<DefaultValueOne, DefaultValueOther> |
186
+ GeneralSingularDefaults<DefaultValueOne, DefaultValueOther> |
187
+ GeneralPluralDefaults<DefaultValueOne, DefaultValueOther> |
188
+ (DefaultValueOther extends Key ? SingularOnlyDefault<DefaultValueOne> : never) |
189
+ (DefaultValueOne extends Key ? PluralOnlyDefault<DefaultValueOther> : never)
190
+ );
191
+
192
+ /** Lookup options that request i18next result metadata. */
193
+ type DetailedOptions<Options> = Options & {
194
+ /** Requests the detailed i18next result object. */
195
+ returnDetails: true;
196
+ };
197
+
198
+ /** Arguments accepted when looking up a generated point translation. */
199
+ type PointLookupArgs<KPrefix extends string | undefined> = {
200
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
201
+ ? Entry extends { kind: "point"; required: boolean }
202
+ ? Entry extends { required: true }
203
+ ? [key: Key, options: EntryOptions<Entry>]
204
+ : [key: Key, options?: EntryOptions<Entry>]
205
+ : never
206
+ : never;
207
+ }[CallKey<KPrefix>];
208
+
209
+ /** Arguments accepted for a generated positional fallback. */
210
+ type DefaultValueArgs<KPrefix extends string | undefined> = {
211
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
212
+ ? Entry extends {
213
+ defaultValue: infer DefaultValue extends string;
214
+ kind: "default" | "plural";
215
+ required: boolean;
216
+ }
217
+ ? Entry extends { required: true }
218
+ ? [key: Key, defaultValue: DefaultValue, options: EntryOptions<Entry>]
219
+ : [key: Key, defaultValue: DefaultValue, options?: EntryOptions<Entry>]
220
+ : never
221
+ : never;
222
+ }[CallKey<KPrefix>];
223
+
224
+ /** A generated key with an object-form fallback value. */
225
+ type ObjectDefaultValueKey<KPrefix extends string | undefined> = {
226
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
227
+ ? Entry extends {
228
+ defaultValue: string;
229
+ kind: "default" | "plural";
230
+ }
231
+ ? Key
232
+ : never
233
+ : never;
234
+ }[CallKey<KPrefix>];
235
+
236
+ /** Options matching the generated object-form fallback for a key. */
237
+ type ObjectDefaultValueOptions<
238
+ Key extends ObjectDefaultValueKey<KPrefix>,
239
+ KPrefix extends string | undefined,
240
+ Entry = ScopedRegistryEntry<Key, KPrefix>,
241
+ > = Entry extends {
242
+ defaultValue: infer DefaultValue extends string;
243
+ kind: "default" | "plural";
244
+ }
245
+ ? DefaultEntryOptions<Entry, DefaultValue>
246
+ : never;
247
+
248
+ /** Arguments accepted for an `other`-only plural fallback. */
249
+ type PluralOtherArgs<KPrefix extends string | undefined> = {
250
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
251
+ ? Entry extends { defaultValue: infer DefaultValue extends string; kind: "plural" }
252
+ ? [key: Key, options: PluralOtherEntryOptions<Entry, DefaultValue>]
253
+ : never
254
+ : never;
255
+ }[CallKey<KPrefix>];
256
+
257
+ /** Arguments accepted for generated singular and plural fallbacks. */
258
+ type PluralDefaultsArgs<KPrefix extends string | undefined> = {
259
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
260
+ ? Entry extends {
261
+ defaultValueOne: infer DefaultValueOne extends string;
262
+ defaultValueOther: infer DefaultValueOther extends string;
263
+ kind: "pluralDefaults";
264
+ }
265
+ ? [
266
+ key: Key,
267
+ options: PluralDefaultsEntryOptions<Entry, Key, DefaultValueOne, DefaultValueOther>,
268
+ ]
269
+ : never
270
+ : never;
271
+ }[CallKey<KPrefix>];
272
+
273
+ /** Detailed-result arguments for a generated point translation. */
274
+ type DetailedPointLookupArgs<KPrefix extends string | undefined> = {
275
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
276
+ ? Entry extends { kind: "point" }
277
+ ? [key: Key, options: DetailedOptions<EntryOptions<Entry>>]
278
+ : never
279
+ : never;
280
+ }[CallKey<KPrefix>];
281
+
282
+ /** Detailed-result arguments for an `other`-only plural fallback. */
283
+ type DetailedPluralOtherArgs<KPrefix extends string | undefined> = {
284
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
285
+ ? Entry extends { defaultValue: infer DefaultValue extends string; kind: "plural" }
286
+ ? [key: Key, options: DetailedOptions<PluralOtherEntryOptions<Entry, DefaultValue>>]
287
+ : never
288
+ : never;
289
+ }[CallKey<KPrefix>];
290
+
291
+ /** Detailed-result arguments for singular and plural fallbacks. */
292
+ type DetailedPluralDefaultsArgs<KPrefix extends string | undefined> = {
293
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
294
+ ? Entry extends {
295
+ defaultValueOne: infer DefaultValueOne extends string;
296
+ defaultValueOther: infer DefaultValueOther extends string;
297
+ kind: "pluralDefaults";
298
+ }
299
+ ? [
300
+ key: Key,
301
+ options: DetailedOptions<
302
+ PluralDefaultsEntryOptions<Entry, Key, DefaultValueOne, DefaultValueOther>
303
+ >,
304
+ ]
305
+ : never
306
+ : never;
307
+ }[CallKey<KPrefix>];
308
+
309
+ /** Detailed-result arguments for a positional fallback. */
310
+ type DetailedDefaultValueArgs<KPrefix extends string | undefined> = {
311
+ [Key in CallKey<KPrefix>]: ScopedRegistryEntry<Key, KPrefix> extends infer Entry
312
+ ? Entry extends {
313
+ defaultValue: infer DefaultValue extends string;
314
+ kind: "default" | "plural";
315
+ }
316
+ ? [key: Key, defaultValue: DefaultValue, options: DetailedOptions<EntryOptions<Entry>>]
317
+ : never
318
+ : never;
319
+ }[CallKey<KPrefix>];
320
+
321
+ /** Point-translation metadata eligible for an i18next fallback array. */
322
+ type FallbackPointEntry<
323
+ Key extends CallKey<KPrefix>,
324
+ KPrefix extends string | undefined,
325
+ > = Extract<ScopedRegistryEntry<Key, KPrefix>, { kind: "point" }>;
326
+
327
+ /** A generated point-translation key eligible for a fallback array. */
328
+ type FallbackPointKey<KPrefix extends string | undefined> = {
329
+ [Key in CallKey<KPrefix>]: [FallbackPointEntry<Key, KPrefix>] extends [never] ? never : Key;
330
+ }[CallKey<KPrefix>];
331
+
332
+ /** Combined generated metadata for a fallback-array branch. */
333
+ type FallbackArrayMetadata<Entries> = {
334
+ /** Whether any fallback entry requires interpolation variables. */
335
+ interpolated: Extract<Entries, { interpolated: true }> extends never ? false : true;
336
+ /** Identifies fallback-array entries as point translations. */
337
+ kind: "point";
338
+ /** Whether any fallback entry requires options. */
339
+ required: Extract<Entries, { required: true }> extends never ? false : true;
340
+ /** The source translation text accepted by the fallback array. */
341
+ value: EntryValue<Entries>;
342
+ };
343
+
344
+ /** Generated metadata for every valid fallback-array context branch. */
345
+ type FallbackArrayEntry<
346
+ Keys extends readonly FallbackPointKey<KPrefix>[],
347
+ KPrefix extends string | undefined,
348
+ Entries = FallbackPointEntry<Keys[number], KPrefix>,
349
+ BaseEntries = Exclude<Entries, { context: string }>,
350
+ Contexts extends string = Extract<Entries, { context: string }> extends infer Contextual
351
+ ? Contextual extends { context: infer Context extends string }
352
+ ? Context
353
+ : never
354
+ : never,
355
+ > = [
356
+ [BaseEntries] extends [never] ? never : FallbackArrayMetadata<BaseEntries>,
357
+ {
358
+ [Context in Contexts]: FallbackArrayMetadata<
359
+ BaseEntries | Extract<Entries, { context: Context }>
360
+ > & {
361
+ context: Context;
362
+ };
363
+ }[Contexts],
364
+ ][number];
365
+
366
+ /** Arguments accepted for a generated fallback-key array. */
367
+ type FallbackArrayArgs<
368
+ Keys extends readonly [FallbackPointKey<KPrefix>, ...FallbackPointKey<KPrefix>[]],
369
+ KPrefix extends string | undefined,
370
+ Entry = FallbackArrayEntry<Keys, KPrefix>,
371
+ > = Entry extends { required: true }
372
+ ? [keys: Keys, options: EntryOptions<Entry>]
373
+ : [keys: Keys, options?: EntryOptions<Entry>];
374
+
375
+ /** Detailed-result arguments for a generated fallback-key array. */
376
+ type DetailedFallbackArrayArgs<
377
+ Keys extends readonly [FallbackPointKey<KPrefix>, ...FallbackPointKey<KPrefix>[]],
378
+ KPrefix extends string | undefined,
379
+ > = [keys: Keys, options: DetailedOptions<EntryOptions<FallbackArrayEntry<Keys, KPrefix>>>];
380
+
381
+ /** Generated default-value metadata eligible for a fallback array. */
382
+ type FallbackDefaultEntry<
383
+ Key extends CallKey<KPrefix>,
384
+ KPrefix extends string | undefined,
385
+ > = Extract<ScopedRegistryEntry<Key, KPrefix>, { kind: "default" }>;
386
+
387
+ /** A generated default-valued key eligible for a fallback array. */
388
+ type FallbackDefaultKey<KPrefix extends string | undefined> = {
389
+ [Key in CallKey<KPrefix>]: [FallbackDefaultEntry<Key, KPrefix>] extends [never] ? never : Key;
390
+ }[CallKey<KPrefix>];
391
+
392
+ /** Key-backed default metadata eligible before an array's final fallback. */
393
+ type FallbackLeadingDefaultEntry<
394
+ Key extends CallKey<KPrefix>,
395
+ KPrefix extends string | undefined,
396
+ > = Extract<FallbackDefaultEntry<Key, KPrefix>, { defaultValue: Key }>;
397
+
398
+ /** A key-backed default entry eligible before an array's final fallback. */
399
+ type FallbackLeadingDefaultKey<KPrefix extends string | undefined> = {
400
+ [Key in CallKey<KPrefix>]: [FallbackLeadingDefaultEntry<Key, KPrefix>] extends [never]
401
+ ? never
402
+ : Key;
403
+ }[CallKey<KPrefix>];
404
+
405
+ /** Generated key tuples carrying an explicit final fallback value. */
406
+ type FallbackDefaultKeys<KPrefix extends string | undefined> = readonly [
407
+ ...FallbackLeadingDefaultKey<KPrefix>[],
408
+ FallbackDefaultKey<KPrefix>,
409
+ ];
410
+
411
+ /** The keys preceding the final element of a fallback tuple. */
412
+ type FallbackLeadingKey<Keys extends readonly string[]> = Keys extends readonly [
413
+ ...infer Leading,
414
+ string,
415
+ ]
416
+ ? Extract<Leading[number], string>
417
+ : never;
418
+
419
+ /** The final key of a fallback tuple. */
420
+ type FallbackLastKey<Keys extends readonly string[]> = Keys extends readonly [
421
+ ...string[],
422
+ infer Last,
423
+ ]
424
+ ? Extract<Last, string>
425
+ : never;
426
+
427
+ /** Generated entries compatible with a selected context branch. */
428
+ type FallbackEntriesInScope<Entries, ScopeEntry> = ScopeEntry extends {
429
+ context: infer Context extends string;
430
+ }
431
+ ? Exclude<Entries, { context: string }> | Extract<Entries, { context: Context }>
432
+ : Exclude<Entries, { context: string }>;
433
+
434
+ /** Combined generated metadata for an explicit-default fallback array. */
435
+ type FallbackDefaultArrayMetadata<Entries, DefaultValue extends string> = {
436
+ /** The explicit fallback text accepted for the final key. */
437
+ defaultValue: DefaultValue;
438
+ /** Whether any fallback entry requires interpolation variables. */
439
+ interpolated: Extract<Entries, { interpolated: true }> extends never ? false : true;
440
+ /** Identifies fallback-array entries carrying an explicit default. */
441
+ kind: "default";
442
+ /** Whether any fallback entry requires options. */
443
+ required: Extract<Entries, { required: true }> extends never ? false : true;
444
+ /** The source translation text accepted by the fallback array. */
445
+ value: EntryValue<Entries>;
446
+ };
447
+
448
+ /** Generated metadata for a fallback array with an explicit final default. */
449
+ type FallbackDefaultArrayEntry<
450
+ Keys extends FallbackDefaultKeys<KPrefix>,
451
+ KPrefix extends string | undefined,
452
+ LeadingKey extends FallbackLeadingDefaultKey<KPrefix> = Extract<
453
+ FallbackLeadingKey<Keys>,
454
+ FallbackLeadingDefaultKey<KPrefix>
455
+ >,
456
+ LastKey extends FallbackDefaultKey<KPrefix> = Extract<
457
+ FallbackLastKey<Keys>,
458
+ FallbackDefaultKey<KPrefix>
459
+ >,
460
+ LeadingEntries = FallbackLeadingDefaultEntry<LeadingKey, KPrefix>,
461
+ LastEntry = FallbackDefaultEntry<LastKey, KPrefix>,
462
+ > = LastEntry extends {
463
+ defaultValue: infer DefaultValue extends string;
464
+ kind: "default";
465
+ }
466
+ ? (
467
+ FallbackDefaultArrayMetadata<
468
+ FallbackEntriesInScope<LeadingEntries, LastEntry> | LastEntry,
469
+ DefaultValue
470
+ > &
471
+ (LastEntry extends { context: infer Context extends string }
472
+ ? { context: Context }
473
+ : Record<never, never>)
474
+ )
475
+ : never;
476
+
477
+ /** Arguments accepted for a generated explicit-default fallback array. */
478
+ type FallbackDefaultArrayArgs<
479
+ Keys extends FallbackDefaultKeys<KPrefix>,
480
+ KPrefix extends string | undefined,
481
+ Entry = FallbackDefaultArrayEntry<Keys, KPrefix>,
482
+ > = Entry extends { defaultValue: infer DefaultValue extends string; required: boolean }
483
+ ? [
484
+ [keys: Keys, options: DefaultEntryOptions<Entry, DefaultValue>],
485
+ Entry extends { required: true }
486
+ ? [keys: Keys, defaultValue: DefaultValue, options: EntryOptions<Entry>]
487
+ : [keys: Keys, defaultValue: DefaultValue, options?: EntryOptions<Entry>],
488
+ ][number]
489
+ : never;
490
+
491
+ /** Detailed-result arguments for an explicit-default fallback array. */
492
+ type DetailedFallbackDefaultArrayArgs<
493
+ Keys extends FallbackDefaultKeys<KPrefix>,
494
+ KPrefix extends string | undefined,
495
+ Entry = FallbackDefaultArrayEntry<Keys, KPrefix>,
496
+ > = Entry extends { defaultValue: infer DefaultValue extends string }
497
+ ? [
498
+ [keys: Keys, options: DetailedOptions<DefaultEntryOptions<Entry, DefaultValue>>],
499
+ [keys: Keys, defaultValue: DefaultValue, options: DetailedOptions<EntryOptions<Entry>>],
500
+ ][number]
501
+ : never;
502
+
503
+ /** Generated natural-plural metadata eligible for a fallback array. */
504
+ type FallbackPluralEntry<
505
+ Key extends CallKey<KPrefix>,
506
+ KPrefix extends string | undefined,
507
+ > = Extract<ScopedRegistryEntry<Key, KPrefix>, { kind: "plural" }>;
508
+
509
+ /** A generated natural-plural key eligible for a fallback array. */
510
+ type FallbackPluralKey<KPrefix extends string | undefined> = {
511
+ [Key in CallKey<KPrefix>]: [FallbackPluralEntry<Key, KPrefix>] extends [never] ? never : Key;
512
+ }[CallKey<KPrefix>];
513
+
514
+ /** Generated key tuples carrying a natural plural fallback. */
515
+ type FallbackPluralKeys<KPrefix extends string | undefined> = readonly [
516
+ FallbackPluralKey<KPrefix>,
517
+ ...FallbackPluralKey<KPrefix>[],
518
+ ];
519
+
520
+ /** Combined generated metadata for a natural-plural fallback array. */
521
+ type FallbackPluralArrayMetadata<Entries> = {
522
+ /** The plural fallback text accepted by the fallback array. */
523
+ defaultValue: Entries extends { defaultValue: infer DefaultValue extends string }
524
+ ? DefaultValue
525
+ : never;
526
+ /** Whether any fallback entry requires interpolation variables. */
527
+ interpolated: Extract<Entries, { interpolated: true }> extends never ? false : true;
528
+ /** Identifies fallback-array entries using a natural plural. */
529
+ kind: "plural";
530
+ /** Marks count and interpolation options as required. */
531
+ required: true;
532
+ /** The singular and plural source text accepted by the fallback array. */
533
+ value: EntryValue<Entries>;
534
+ };
535
+
536
+ /** Generated metadata for every natural-plural fallback-array branch. */
537
+ type FallbackPluralArrayEntry<
538
+ Keys extends FallbackPluralKeys<KPrefix>,
539
+ KPrefix extends string | undefined,
540
+ Entries = FallbackPluralEntry<Keys[number], KPrefix>,
541
+ BaseEntries = Exclude<Entries, { context: string }>,
542
+ Contexts extends string = Extract<Entries, { context: string }> extends infer Contextual
543
+ ? Contextual extends { context: infer Context extends string }
544
+ ? Context
545
+ : never
546
+ : never,
547
+ > = [
548
+ [BaseEntries] extends [never] ? never : FallbackPluralArrayMetadata<BaseEntries>,
549
+ {
550
+ [Context in Contexts]: FallbackPluralArrayMetadata<
551
+ BaseEntries | Extract<Entries, { context: Context }>
552
+ > & {
553
+ context: Context;
554
+ };
555
+ }[Contexts],
556
+ ][number];
557
+
558
+ /** Arguments accepted for a generated natural-plural fallback array. */
559
+ type FallbackPluralArrayArgs<
560
+ Keys extends FallbackPluralKeys<KPrefix>,
561
+ KPrefix extends string | undefined,
562
+ Entry = FallbackPluralArrayEntry<Keys, KPrefix>,
563
+ > = Entry extends { defaultValue: infer DefaultValue extends string }
564
+ ? [
565
+ [keys: Keys, defaultValue: DefaultValue, options: EntryOptions<Entry>],
566
+ [
567
+ keys: Keys,
568
+ options:
569
+ DefaultEntryOptions<Entry, DefaultValue> |
570
+ PluralOtherEntryOptions<Entry, DefaultValue>,
571
+ ],
572
+ ][number]
573
+ : never;
574
+
575
+ /** Detailed-result arguments for a natural-plural fallback array. */
576
+ type DetailedFallbackPluralArrayArgs<
577
+ Keys extends FallbackPluralKeys<KPrefix>,
578
+ KPrefix extends string | undefined,
579
+ Entry = FallbackPluralArrayEntry<Keys, KPrefix>,
580
+ > = Entry extends { defaultValue: infer DefaultValue extends string }
581
+ ? [
582
+ [
583
+ keys: Keys,
584
+ defaultValue: DefaultValue,
585
+ options: DetailedOptions<EntryOptions<Entry>>,
586
+ ],
587
+ [
588
+ keys: Keys,
589
+ options: DetailedOptions<
590
+ DefaultEntryOptions<Entry, DefaultValue> |
591
+ PluralOtherEntryOptions<Entry, DefaultValue>
592
+ >,
593
+ ],
594
+ ][number]
595
+ : never;
596
+
597
+ /** Generated explicit-plural metadata eligible for a fallback array. */
598
+ type FallbackPluralDefaultsEntry<
599
+ Key extends CallKey<KPrefix>,
600
+ KPrefix extends string | undefined,
601
+ > = Extract<ScopedRegistryEntry<Key, KPrefix>, { kind: "pluralDefaults" }>;
602
+
603
+ /** A generated explicit-plural key eligible for a fallback array. */
604
+ type FallbackPluralDefaultsKey<KPrefix extends string | undefined> = {
605
+ [Key in CallKey<KPrefix>]: [FallbackPluralDefaultsEntry<Key, KPrefix>] extends [never]
606
+ ? never
607
+ : Key;
608
+ }[CallKey<KPrefix>];
609
+
610
+ /** Generated key tuples carrying explicit singular and plural defaults. */
611
+ type FallbackPluralDefaultsKeys<KPrefix extends string | undefined> = readonly [
612
+ FallbackPluralDefaultsKey<KPrefix>,
613
+ ...FallbackPluralDefaultsKey<KPrefix>[],
614
+ ];
615
+
616
+ /** Combined generated metadata for an explicit-plural fallback array. */
617
+ type FallbackPluralDefaultsArrayMetadata<Entries> = {
618
+ /** The singular fallback text accepted by the fallback array. */
619
+ defaultValueOne: Entries extends { defaultValueOne: infer DefaultValueOne extends string }
620
+ ? DefaultValueOne
621
+ : never;
622
+ /** The plural fallback text accepted by the fallback array. */
623
+ defaultValueOther: Entries extends {
624
+ defaultValueOther: infer DefaultValueOther extends string;
625
+ }
626
+ ? DefaultValueOther
627
+ : never;
628
+ /** Whether any fallback entry requires interpolation variables. */
629
+ interpolated: Extract<Entries, { interpolated: true }> extends never ? false : true;
630
+ /** Identifies fallback-array entries using explicit plural defaults. */
631
+ kind: "pluralDefaults";
632
+ /** Marks count and interpolation options as required. */
633
+ required: true;
634
+ /** The singular and plural source text accepted by the fallback array. */
635
+ value: EntryValue<Entries>;
636
+ };
637
+
638
+ /** Generated metadata for every explicit-plural fallback-array branch. */
639
+ type FallbackPluralDefaultsArrayEntry<
640
+ Keys extends FallbackPluralDefaultsKeys<KPrefix>,
641
+ KPrefix extends string | undefined,
642
+ Entries = FallbackPluralDefaultsEntry<Keys[number], KPrefix>,
643
+ BaseEntries = Exclude<Entries, { context: string }>,
644
+ Contexts extends string = Extract<Entries, { context: string }> extends infer Contextual
645
+ ? Contextual extends { context: infer Context extends string }
646
+ ? Context
647
+ : never
648
+ : never,
649
+ > = [
650
+ [BaseEntries] extends [never] ? never : FallbackPluralDefaultsArrayMetadata<BaseEntries>,
651
+ {
652
+ [Context in Contexts]: FallbackPluralDefaultsArrayMetadata<
653
+ BaseEntries | Extract<Entries, { context: Context }>
654
+ > & {
655
+ context: Context;
656
+ };
657
+ }[Contexts],
658
+ ][number];
659
+
660
+ /** Arguments accepted for an explicit-plural fallback array. */
661
+ type FallbackPluralDefaultsArrayArgs<
662
+ Keys extends FallbackPluralDefaultsKeys<KPrefix>,
663
+ KPrefix extends string | undefined,
664
+ Entry = FallbackPluralDefaultsArrayEntry<Keys, KPrefix>,
665
+ > = Entry extends {
666
+ defaultValueOne: infer DefaultValueOne extends string;
667
+ defaultValueOther: infer DefaultValueOther extends string;
668
+ }
669
+ ? [
670
+ keys: Keys,
671
+ options: PluralDefaultsEntryOptions<
672
+ Entry,
673
+ Keys[number],
674
+ DefaultValueOne,
675
+ DefaultValueOther
676
+ >,
677
+ ]
678
+ : never;
679
+
680
+ /** Detailed-result arguments for an explicit-plural fallback array. */
681
+ type DetailedFallbackPluralDefaultsArrayArgs<
682
+ Keys extends FallbackPluralDefaultsKeys<KPrefix>,
683
+ KPrefix extends string | undefined,
684
+ Entry = FallbackPluralDefaultsArrayEntry<Keys, KPrefix>,
685
+ > = Entry extends {
686
+ defaultValueOne: infer DefaultValueOne extends string;
687
+ defaultValueOther: infer DefaultValueOther extends string;
688
+ }
689
+ ? [
690
+ keys: Keys,
691
+ options: DetailedOptions<
692
+ PluralDefaultsEntryOptions<
693
+ Entry,
694
+ Keys[number],
695
+ DefaultValueOne,
696
+ DefaultValueOther
697
+ >
698
+ >,
699
+ ]
700
+ : never;
701
+
702
+ /** The i18next result returned when `returnDetails` is enabled. */
703
+ type DetailedResult = TFunctionDetailedResult<string, TOptions & { returnDetails: true }>;
704
+
705
+ /** Object-form fallback arguments accepted by a generated key. */
706
+ type ObjectDefaultValueTuple<KPrefix extends string | undefined> = {
707
+ [Key in ObjectDefaultValueKey<KPrefix>]: [
708
+ key: Key,
709
+ options: ObjectDefaultValueOptions<Key, KPrefix>,
710
+ ];
711
+ }[ObjectDefaultValueKey<KPrefix>];
712
+
713
+ /** Detailed-result object-form fallback arguments for a generated key. */
714
+ type DetailedObjectDefaultValueTuple<KPrefix extends string | undefined> = {
715
+ [Key in ObjectDefaultValueKey<KPrefix>]: [
716
+ key: Key,
717
+ options: DetailedOptions<ObjectDefaultValueOptions<Key, KPrefix>>,
718
+ ];
719
+ }[ObjectDefaultValueKey<KPrefix>];
720
+
721
+ /** Lookup options carrying an explicit call-level key prefix. */
722
+ type RequiredCallPrefixOptions<Options, Prefix extends string> = Omit<
723
+ Exclude<Options, undefined>,
724
+ "keyPrefix"
725
+ > & {
726
+ /** The key prefix applied to this translation call. */
727
+ keyPrefix: Prefix;
728
+ };
729
+
730
+ /** Adds a required call-level key prefix to an argument tuple. */
731
+ type CallPrefixArgs<Args, Prefix extends string> = Args extends [
732
+ key: infer Key,
733
+ defaultValue: infer DefaultValue extends string,
734
+ options?: infer Options,
735
+ ]
736
+ ? [
737
+ key: Key,
738
+ defaultValue: DefaultValue,
739
+ options: RequiredCallPrefixOptions<Options, Prefix>,
740
+ ]
741
+ : Args extends [key: infer Key, options?: infer Options]
742
+ ? [key: Key, options: RequiredCallPrefixOptions<Options, Prefix>]
743
+ : never;
744
+
745
+ /** Scalar lookup arguments using a call-level key prefix. */
746
+ type ScalarCallPrefixArgs<Prefix extends string> = CallPrefixArgs<
747
+ | PointLookupArgs<Prefix> |
748
+ DefaultValueArgs<Prefix> |
749
+ ObjectDefaultValueTuple<Prefix> |
750
+ PluralOtherArgs<Prefix> |
751
+ PluralDefaultsArgs<Prefix>,
752
+ Prefix
753
+ >;
754
+
755
+ /** Detailed-result scalar arguments using a call-level key prefix. */
756
+ type DetailedScalarCallPrefixArgs<Prefix extends string> = CallPrefixArgs<
757
+ | DetailedPointLookupArgs<Prefix> |
758
+ DetailedDefaultValueArgs<Prefix> |
759
+ DetailedObjectDefaultValueTuple<Prefix> |
760
+ DetailedPluralOtherArgs<Prefix> |
761
+ DetailedPluralDefaultsArgs<Prefix>,
762
+ Prefix
763
+ >;
764
+
765
+ /** Translation overloads derived from generated source metadata. */
766
+ type GeneratedTFunction<KPrefix extends string | undefined> = Pick<
767
+ UpstreamTFunction,
768
+ "$TFunctionBrand"
769
+ > & {
770
+ <const Keys extends FallbackDefaultKeys<KPrefix>>(
771
+ ...args: DetailedFallbackDefaultArrayArgs<Keys, KPrefix>
772
+ ): DetailedResult;
773
+ <const Keys extends FallbackPluralKeys<KPrefix>>(
774
+ ...args: DetailedFallbackPluralArrayArgs<Keys, KPrefix>
775
+ ): DetailedResult;
776
+ <const Keys extends FallbackPluralDefaultsKeys<KPrefix>>(
777
+ ...args: DetailedFallbackPluralDefaultsArrayArgs<Keys, KPrefix>
778
+ ): DetailedResult;
779
+ <const Keys extends readonly [FallbackPointKey<KPrefix>, ...FallbackPointKey<KPrefix>[]]>(
780
+ ...args: DetailedFallbackArrayArgs<Keys, KPrefix>
781
+ ): DetailedResult;
782
+ (...args: DetailedPointLookupArgs<KPrefix>): DetailedResult;
783
+ (...args: DetailedDefaultValueArgs<KPrefix>): DetailedResult;
784
+ <const Key extends ObjectDefaultValueKey<KPrefix>>(
785
+ key: Key,
786
+ options: DetailedOptions<ObjectDefaultValueOptions<Key, KPrefix>>,
787
+ ): DetailedResult;
788
+ (...args: DetailedPluralOtherArgs<KPrefix>): DetailedResult;
789
+ (...args: DetailedPluralDefaultsArgs<KPrefix>): DetailedResult;
790
+ <const Keys extends FallbackDefaultKeys<KPrefix>>(
791
+ ...args: FallbackDefaultArrayArgs<Keys, KPrefix>
792
+ ): string;
793
+ <const Keys extends FallbackPluralKeys<KPrefix>>(
794
+ ...args: FallbackPluralArrayArgs<Keys, KPrefix>
795
+ ): string;
796
+ <const Keys extends FallbackPluralDefaultsKeys<KPrefix>>(
797
+ ...args: FallbackPluralDefaultsArrayArgs<Keys, KPrefix>
798
+ ): string;
799
+ <const Keys extends readonly [FallbackPointKey<KPrefix>, ...FallbackPointKey<KPrefix>[]]>(
800
+ ...args: FallbackArrayArgs<Keys, KPrefix>
801
+ ): string;
802
+ (...args: PointLookupArgs<KPrefix>): string;
803
+ (...args: DefaultValueArgs<KPrefix>): string;
804
+ <const Key extends ObjectDefaultValueKey<KPrefix>>(
805
+ key: Key,
806
+ options: ObjectDefaultValueOptions<Key, KPrefix>,
807
+ ): string;
808
+ (...args: PluralOtherArgs<KPrefix>): string;
809
+ (...args: PluralDefaultsArgs<KPrefix>): string;
810
+ };
811
+
812
+ /** Generated translation overloads with per-call key prefixes. */
813
+ type GeneratedCallPrefixTFunction = {
814
+ <const Prefix extends string, const Keys extends FallbackDefaultKeys<Prefix>>(
815
+ ...args: CallPrefixArgs<DetailedFallbackDefaultArrayArgs<Keys, Prefix>, Prefix>
816
+ ): DetailedResult;
817
+ <const Prefix extends string, const Keys extends FallbackPluralKeys<Prefix>>(
818
+ ...args: CallPrefixArgs<DetailedFallbackPluralArrayArgs<Keys, Prefix>, Prefix>
819
+ ): DetailedResult;
820
+ <const Prefix extends string, const Keys extends FallbackPluralDefaultsKeys<Prefix>>(
821
+ ...args: CallPrefixArgs<DetailedFallbackPluralDefaultsArrayArgs<Keys, Prefix>, Prefix>
822
+ ): DetailedResult;
823
+ <
824
+ const Prefix extends string,
825
+ const Keys extends readonly [FallbackPointKey<Prefix>, ...FallbackPointKey<Prefix>[]],
826
+ >(...args: CallPrefixArgs<DetailedFallbackArrayArgs<Keys, Prefix>, Prefix>): DetailedResult;
827
+ <const Prefix extends string>(...args: DetailedScalarCallPrefixArgs<Prefix>): DetailedResult;
828
+ <const Prefix extends string, const Keys extends FallbackDefaultKeys<Prefix>>(
829
+ ...args: CallPrefixArgs<FallbackDefaultArrayArgs<Keys, Prefix>, Prefix>
830
+ ): string;
831
+ <const Prefix extends string, const Keys extends FallbackPluralKeys<Prefix>>(
832
+ ...args: CallPrefixArgs<FallbackPluralArrayArgs<Keys, Prefix>, Prefix>
833
+ ): string;
834
+ <const Prefix extends string, const Keys extends FallbackPluralDefaultsKeys<Prefix>>(
835
+ ...args: CallPrefixArgs<FallbackPluralDefaultsArrayArgs<Keys, Prefix>, Prefix>
836
+ ): string;
837
+ <
838
+ const Prefix extends string,
839
+ const Keys extends readonly [FallbackPointKey<Prefix>, ...FallbackPointKey<Prefix>[]],
840
+ >(...args: CallPrefixArgs<FallbackArrayArgs<Keys, Prefix>, Prefix>): string;
841
+ <const Prefix extends string>(...args: ScalarCallPrefixArgs<Prefix>): string;
842
+ };
843
+
844
+ /** Generated translation overloads available to a fixed translation function. */
845
+ type GeneratedFixedTFunction<KPrefix extends string | undefined> = GeneratedTFunction<KPrefix> &
846
+ GeneratedCallPrefixTFunction;
847
+
848
+ /** The application's translation function, narrowed by generated metadata when available. */
849
+ type TFunction<KPrefix extends string | undefined = undefined> = IsRegistryEmpty extends true
850
+ ? UpstreamTFunction<"translation", KPrefix>
851
+ : GeneratedTFunction<KPrefix>;
852
+
853
+ /** A fixed i18next translation function narrowed by generated metadata. */
854
+ type FixedTFunction<KPrefix extends string | undefined = undefined> = IsRegistryEmpty extends true
855
+ ? UpstreamTFunction<"translation", KPrefix>
856
+ : GeneratedFixedTFunction<KPrefix>;
857
+
858
+ /** Generated overloads for creating a fixed translation function. */
859
+ type GeneratedGetFixedT = {
860
+ <const KPrefix extends string | undefined = undefined>(
861
+ lng: string | readonly string[],
862
+ ns?: Namespace | null,
863
+ keyPrefix?: KPrefix,
864
+ ): FixedTFunction<NormalizedKeyPrefix<KPrefix>>;
865
+ <const KPrefix extends string | undefined = undefined>(
866
+ lng: null,
867
+ ns: Namespace | null,
868
+ keyPrefix?: KPrefix,
869
+ ): FixedTFunction<NormalizedKeyPrefix<KPrefix>>;
870
+ };
871
+
872
+ /** The shared i18next instance narrowed by generated translation metadata. */
873
+ type ConfiguredI18n = IsRegistryEmpty extends true
874
+ ? I18n
875
+ : Omit<I18n, "getFixedT" | "init" | "t"> & {
876
+ getFixedT: GeneratedGetFixedT;
877
+ init: Init;
878
+ t: TFunction;
879
+ };
880
+
881
+ /** Returns the shared configured i18next instance. */
882
+ type GetI18n = () => ConfiguredI18n;
883
+
884
+ /** The generated call signature for the React `Trans` component. */
885
+ type GeneratedTransCall = <
886
+ const Key extends string = string,
887
+ Ns extends Namespace = "translation",
888
+ KPrefix extends string | undefined = undefined,
889
+ TContext extends string | undefined = undefined,
890
+ TOpt extends TOptions & { context?: TContext } = { context: TContext },
891
+ Ret = string,
892
+ E = React.HTMLProps<HTMLDivElement>,
893
+ >(
894
+ props: Omit<UpstreamTransProps<Key, Ns, KPrefix, TContext, TOpt, Ret, E>, "t"> & {
895
+ t?: FixedTFunction<NormalizedKeyPrefix<KPrefix>> | TFunction;
896
+ },
897
+ ) => React.ReactElement;
898
+
899
+ /** The generated call signature for the React `IcuTrans` component. */
900
+ type GeneratedIcuTransCall = <
901
+ const Key extends string = string,
902
+ Ns extends Namespace = "translation",
903
+ KPrefix extends string | undefined = undefined,
904
+ TContext extends string | undefined = undefined,
905
+ TOpt extends TOptions & { context?: TContext } = { context: TContext },
906
+ >(
907
+ props: Omit<UpstreamIcuTransProps<Key, Ns, KPrefix, TContext, TOpt>, "t"> & {
908
+ t?: FixedTFunction<NormalizedKeyPrefix<KPrefix>> | TFunction;
909
+ },
910
+ ) => React.ReactElement;
911
+
912
+ /** The generated call signature for context-free React ICU translations. */
913
+ type GeneratedIcuTransWithoutContextCall = <
914
+ const Key extends string = string,
915
+ Ns extends Namespace = "translation",
916
+ KPrefix extends string | undefined = undefined,
917
+ TContext extends string | undefined = undefined,
918
+ TOpt extends TOptions & { context?: TContext } = { context: TContext },
919
+ >(
920
+ props: Omit<
921
+ UpstreamIcuTransWithoutContextProps<Key, Ns, KPrefix, TContext, TOpt>,
922
+ "t"
923
+ > & {
924
+ t?: FixedTFunction<NormalizedKeyPrefix<KPrefix>> | TFunction;
925
+ },
926
+ ) => React.ReactElement;
927
+
928
+ /** The react-i18next `Trans` component narrowed by generated metadata. */
929
+ type TransComponent = IsRegistryEmpty extends true
930
+ ? typeof upstreamTrans
931
+ : GeneratedTransCall;
932
+
933
+ /** The react-i18next context-free `Trans` component narrowed by generated metadata. */
934
+ type TransWithoutContextComponent = IsRegistryEmpty extends true
935
+ ? typeof upstreamTransWithoutContext
936
+ : GeneratedTransCall;
937
+
938
+ /** The react-i18next `IcuTrans` component narrowed by generated metadata. */
939
+ type IcuTransComponent = IsRegistryEmpty extends true
940
+ ? typeof upstreamIcuTrans
941
+ : GeneratedIcuTransCall;
942
+
943
+ /** The context-free react-i18next ICU component narrowed by generated metadata. */
944
+ type IcuTransWithoutContextComponent = IsRegistryEmpty extends true
945
+ ? typeof upstreamIcuTransWithoutContext
946
+ : GeneratedIcuTransWithoutContextCall;
947
+
948
+ /** The generated tuple and named fields returned by `useTranslation`. */
949
+ type GeneratedUseTranslationResponse<KPrefix extends string | undefined> = [
950
+ t: FixedTFunction<KPrefix>,
951
+ i18n: ConfiguredI18n,
952
+ ready: boolean,
953
+ ] &
954
+ Omit<UpstreamUseTranslationResponse<"translation", undefined>, 0 | 1 | "i18n" | "t"> &
955
+ Record<"i18n", ConfiguredI18n> &
956
+ Record<"t", FixedTFunction<KPrefix>>;
957
+
958
+ /** The result returned by {@link useTranslation}. */
959
+ type UseTranslationResponse<Ns extends Namespace = "translation", KPrefix = undefined> =
960
+ IsRegistryEmpty extends true
961
+ ? UpstreamUseTranslationResponse<Ns, KPrefix>
962
+ : GeneratedUseTranslationResponse<NormalizedKeyPrefix<KPrefix>>;
963
+
964
+ /** The generated signature for the react-i18next `useTranslation` hook. */
965
+ type GeneratedUseTranslation = <
966
+ const Ns extends FlatNamespace | readonly FlatNamespace[] | undefined = undefined,
967
+ const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
968
+ >(
969
+ ns?: Ns,
970
+ options?: UseTranslationOptions<KPrefix>,
971
+ ) => UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
972
+
973
+ /** The react-i18next `useTranslation` hook narrowed by generated metadata. */
974
+ type UseTranslation = IsRegistryEmpty extends true ? typeof upstreamUseTranslation : GeneratedUseTranslation;
975
+
976
+ /** Generated translation props injected by `withTranslation`. */
977
+ type GeneratedWithTranslation<KPrefix extends string | undefined> = Omit<
978
+ UpstreamWithTranslation,
979
+ "i18n" | "t"
980
+ > &
981
+ Record<"i18n", ConfiguredI18n> &
982
+ Record<"t", FixedTFunction<KPrefix>>;
983
+
984
+ /** Props injected by {@link withTranslation}. */
985
+ type WithTranslation<
986
+ Ns extends FlatNamespace | readonly FlatNamespace[] | undefined = undefined,
987
+ KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
988
+ > = IsRegistryEmpty extends true
989
+ ? UpstreamWithTranslation<Ns, KPrefix>
990
+ : GeneratedWithTranslation<NormalizedKeyPrefix<KPrefix>>;
991
+
992
+ /** The generated signature for the `withTranslation` higher-order component. */
993
+ type GeneratedWithTranslationFactory = <
994
+ const Ns extends FlatNamespace | readonly FlatNamespace[] | undefined = undefined,
995
+ const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
996
+ >(
997
+ ns?: Ns,
998
+ options?: {
999
+ withRef?: boolean;
1000
+ keyPrefix?: KPrefix;
1001
+ },
1002
+ ) => <
1003
+ Component extends React.ElementType,
1004
+ ResolvedProps = React.JSX.LibraryManagedAttributes<
1005
+ Component,
1006
+ Omit<React.ComponentProps<Component>, keyof WithTranslationProps>
1007
+ >,
1008
+ >(
1009
+ component: Component,
1010
+ ) => React.ComponentType<
1011
+ Omit<ResolvedProps, keyof WithTranslation<Ns, KPrefix>> & WithTranslationProps
1012
+ >;
1013
+
1014
+ /** The react-i18next `withTranslation` factory narrowed by generated metadata. */
1015
+ type WithTranslationFactory = IsRegistryEmpty extends true
1016
+ ? typeof upstreamWithTranslation
1017
+ : GeneratedWithTranslationFactory;
1018
+
1019
+ /** The render callback accepted by the React `Translation` component. */
1020
+ type TranslationChildren<KPrefix extends string | undefined> = (
1021
+ t: FixedTFunction<KPrefix>,
1022
+ options: Omit<Parameters<UpstreamTranslationProps<"translation">["children"]>[1], "i18n"> &
1023
+ Record<"i18n", ConfiguredI18n>,
1024
+ isReady: boolean,
1025
+ ) => React.ReactNode;
1026
+
1027
+ /** Generated props for the React `Translation` component. */
1028
+ type GeneratedTranslationProps<
1029
+ Ns extends FlatNamespace | readonly FlatNamespace[] | undefined,
1030
+ KPrefix extends KeyPrefix<FallbackNs<Ns>>,
1031
+ > = Omit<UpstreamTranslationProps<Ns, KPrefix>, "children"> &
1032
+ Record<"children", TranslationChildren<NormalizedKeyPrefix<KPrefix>>>;
1033
+
1034
+ /** Props accepted by {@link Translation}. */
1035
+ type TranslationProps<
1036
+ Ns extends FlatNamespace | readonly FlatNamespace[] | undefined = undefined,
1037
+ KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
1038
+ > = IsRegistryEmpty extends true
1039
+ ? UpstreamTranslationProps<Ns, KPrefix>
1040
+ : GeneratedTranslationProps<Ns, KPrefix>;
1041
+
1042
+ /** The generated call signature for the React `Translation` component. */
1043
+ type GeneratedTranslationComponent = <
1044
+ const Ns extends FlatNamespace | readonly FlatNamespace[] | undefined = undefined,
1045
+ const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
1046
+ >(
1047
+ props: TranslationProps<Ns, KPrefix>,
1048
+ ) => React.ReactNode;
1049
+
1050
+ /** The react-i18next `Translation` component narrowed by generated metadata. */
1051
+ type TranslationComponent = IsRegistryEmpty extends true
1052
+ ? typeof upstreamTranslation
1053
+ : GeneratedTranslationComponent;
1054
+
1055
+ /** The callback accepted by generated `init` overloads. */
1056
+ type GeneratedCallback = (error: Parameters<Callback>[0], t: TFunction) => void;
1057
+
1058
+ /** Generated initialization overloads returning the narrowed translation function. */
1059
+ type GeneratedInit = {
1060
+ (callback?: GeneratedCallback): Promise<TFunction>;
1061
+ <Options>(options: InitOptions<Options>, callback?: GeneratedCallback): Promise<TFunction>;
1062
+ };
1063
+
1064
+ /** The i18next initialization function narrowed by generated metadata. */
1065
+ type Init = IsRegistryEmpty extends true ? I18n["init"] : GeneratedInit;
1066
+
1067
+ export type {
1068
+ GetI18n,
1069
+ IcuTransComponent,
1070
+ IcuTransWithoutContextComponent,
1071
+ Init,
1072
+ TFunction,
1073
+ TransComponent,
1074
+ TransWithoutContextComponent,
1075
+ TranslationComponent,
1076
+ TranslationProps,
1077
+ UseTranslation,
1078
+ UseTranslationResponse,
1079
+ WithTranslation,
1080
+ WithTranslationFactory,
1081
+ };