i18next 23.7.2 → 23.7.4
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/dist/esm/package.json +1 -1
- package/index.v4.d.ts +544 -0
- package/package.json +6 -2
- package/typescript/t.d.ts +2 -2
- package/typescript/t.v4.d.ts +2 -2
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"23.7.
|
|
1
|
+
{"type":"module","version":"23.7.4"}
|
package/index.v4.d.ts
ADDED
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
// Internal Helpers
|
|
2
|
+
import type { $Dictionary } from './typescript/helpers.d.ts';
|
|
3
|
+
import type {
|
|
4
|
+
DefaultNamespace,
|
|
5
|
+
FlatNamespace,
|
|
6
|
+
FormatFunction,
|
|
7
|
+
InitOptions,
|
|
8
|
+
InterpolationOptions,
|
|
9
|
+
Namespace,
|
|
10
|
+
Resource,
|
|
11
|
+
ResourceKey,
|
|
12
|
+
ResourceLanguage,
|
|
13
|
+
TOptions,
|
|
14
|
+
} from './typescript/options.d.ts';
|
|
15
|
+
|
|
16
|
+
import type { KeyPrefix, TFunction } from './typescript/t.d.ts';
|
|
17
|
+
|
|
18
|
+
export interface WithT<Ns extends Namespace = DefaultNamespace> {
|
|
19
|
+
// Expose parameterized t in the i18next interface hierarchy
|
|
20
|
+
t: TFunction<Ns>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Interpolator {
|
|
24
|
+
init(options: InterpolationOptions, reset: boolean): undefined;
|
|
25
|
+
reset(): undefined;
|
|
26
|
+
resetRegExp(): undefined;
|
|
27
|
+
interpolate(str: string, data: object, lng: string, options: InterpolationOptions): string;
|
|
28
|
+
nest(str: string, fc: (...args: any[]) => any, options: InterpolationOptions): string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class ResourceStore {
|
|
32
|
+
constructor(data: Resource, options: InitOptions);
|
|
33
|
+
|
|
34
|
+
public data: Resource;
|
|
35
|
+
public options: InitOptions;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Gets fired when resources got added or removed
|
|
39
|
+
*/
|
|
40
|
+
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
|
|
41
|
+
/**
|
|
42
|
+
* Remove event listener
|
|
43
|
+
* removes all callback when callback not specified
|
|
44
|
+
*/
|
|
45
|
+
off(event: 'added' | 'removed', callback?: (lng: string, ns: string) => void): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface Formatter {
|
|
49
|
+
init(services: Services, i18nextOptions: InitOptions): void;
|
|
50
|
+
add(name: string, fc: (value: any, lng: string | undefined, options: any) => string): void;
|
|
51
|
+
addCached(
|
|
52
|
+
name: string,
|
|
53
|
+
fc: (lng: string | undefined, options: any) => (value: any) => string,
|
|
54
|
+
): void;
|
|
55
|
+
format: FormatFunction;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface Services {
|
|
59
|
+
backendConnector: any;
|
|
60
|
+
i18nFormat: any;
|
|
61
|
+
interpolator: Interpolator;
|
|
62
|
+
languageDetector: any;
|
|
63
|
+
languageUtils: any;
|
|
64
|
+
logger: any;
|
|
65
|
+
pluralResolver: any;
|
|
66
|
+
resourceStore: ResourceStore;
|
|
67
|
+
formatter?: Formatter;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type ModuleType =
|
|
71
|
+
| 'backend'
|
|
72
|
+
| 'logger'
|
|
73
|
+
| 'languageDetector'
|
|
74
|
+
| 'postProcessor'
|
|
75
|
+
| 'i18nFormat'
|
|
76
|
+
| 'formatter'
|
|
77
|
+
| '3rdParty';
|
|
78
|
+
|
|
79
|
+
export interface Module {
|
|
80
|
+
type: ModuleType;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type CallbackError = Error | string | null | undefined;
|
|
84
|
+
export type ReadCallback = (
|
|
85
|
+
err: CallbackError,
|
|
86
|
+
data: ResourceKey | boolean | null | undefined,
|
|
87
|
+
) => void;
|
|
88
|
+
export type MultiReadCallback = (err: CallbackError, data: Resource | null | undefined) => void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Used to load data for i18next.
|
|
92
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
93
|
+
* For singleton set property `type` to `'backend'` For a prototype constructor set static property.
|
|
94
|
+
*/
|
|
95
|
+
export interface BackendModule<TOptions = object> extends Module {
|
|
96
|
+
type: 'backend';
|
|
97
|
+
init(services: Services, backendOptions: TOptions, i18nextOptions: InitOptions): void;
|
|
98
|
+
read(language: string, namespace: string, callback: ReadCallback): void;
|
|
99
|
+
/** Save the missing translation */
|
|
100
|
+
create?(
|
|
101
|
+
languages: readonly string[],
|
|
102
|
+
namespace: string,
|
|
103
|
+
key: string,
|
|
104
|
+
fallbackValue: string,
|
|
105
|
+
): void;
|
|
106
|
+
/** Load multiple languages and namespaces. For backends supporting multiple resources loading */
|
|
107
|
+
readMulti?(
|
|
108
|
+
languages: readonly string[],
|
|
109
|
+
namespaces: readonly string[],
|
|
110
|
+
callback: MultiReadCallback,
|
|
111
|
+
): void;
|
|
112
|
+
/** Store the translation. For backends acting as cache layer */
|
|
113
|
+
save?(language: string, namespace: string, data: ResourceLanguage): void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Used to detect language in user land.
|
|
118
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
119
|
+
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
|
120
|
+
*/
|
|
121
|
+
export interface LanguageDetectorModule extends Module {
|
|
122
|
+
type: 'languageDetector';
|
|
123
|
+
init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
|
124
|
+
/** Must return detected language */
|
|
125
|
+
detect(): string | readonly string[] | undefined;
|
|
126
|
+
cacheUserLanguage?(lng: string): void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Used to detect language in user land.
|
|
131
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
132
|
+
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
|
133
|
+
*/
|
|
134
|
+
export interface LanguageDetectorAsyncModule extends Module {
|
|
135
|
+
type: 'languageDetector';
|
|
136
|
+
/** Set to true to enable async detection */
|
|
137
|
+
async: true;
|
|
138
|
+
init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
|
139
|
+
/** Must call callback passing detected language or return a Promise*/
|
|
140
|
+
detect(
|
|
141
|
+
callback: (lng: string | readonly string[] | undefined) => void | undefined,
|
|
142
|
+
): void | Promise<string | readonly string[] | undefined>;
|
|
143
|
+
cacheUserLanguage?(lng: string): void | Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Used to extend or manipulate the translated values before returning them in `t` function.
|
|
148
|
+
* Need to be a singleton object.
|
|
149
|
+
*/
|
|
150
|
+
export interface PostProcessorModule extends Module {
|
|
151
|
+
/** Unique name */
|
|
152
|
+
name: string;
|
|
153
|
+
type: 'postProcessor';
|
|
154
|
+
process(value: string, key: string | string[], options: TOptions, translator: any): string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Override the built-in console logger.
|
|
159
|
+
* Do not need to be a prototype function.
|
|
160
|
+
*/
|
|
161
|
+
export interface LoggerModule extends Module {
|
|
162
|
+
type: 'logger';
|
|
163
|
+
log(...args: any[]): void;
|
|
164
|
+
warn(...args: any[]): void;
|
|
165
|
+
error(...args: any[]): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface I18nFormatModule extends Module {
|
|
169
|
+
type: 'i18nFormat';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface FormatterModule extends Module, Formatter {
|
|
173
|
+
type: 'formatter';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface ThirdPartyModule extends Module {
|
|
177
|
+
type: '3rdParty';
|
|
178
|
+
init(i18next: i18n): void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface Modules {
|
|
182
|
+
backend?: BackendModule;
|
|
183
|
+
logger?: LoggerModule;
|
|
184
|
+
languageDetector?: LanguageDetectorModule | LanguageDetectorAsyncModule;
|
|
185
|
+
i18nFormat?: I18nFormatModule;
|
|
186
|
+
formatter?: FormatterModule;
|
|
187
|
+
external: ThirdPartyModule[];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// helper to identify class https://stackoverflow.com/a/45983481/2363935
|
|
191
|
+
export interface Newable<T> {
|
|
192
|
+
new (...args: any[]): T;
|
|
193
|
+
}
|
|
194
|
+
export interface NewableModule<T extends Module> extends Newable<T> {
|
|
195
|
+
type: T['type'];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export type Callback = (error: any, t: TFunction) => void;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Uses similar args as the t function and returns true if a key exists.
|
|
202
|
+
*/
|
|
203
|
+
export interface ExistsFunction<
|
|
204
|
+
TKeys extends string = string,
|
|
205
|
+
TInterpolationMap extends object = $Dictionary,
|
|
206
|
+
> {
|
|
207
|
+
(key: TKeys | TKeys[], options?: TOptions<TInterpolationMap>): boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface CloneOptions extends InitOptions {
|
|
211
|
+
/**
|
|
212
|
+
* Will create a new instance of the resource store and import the existing translation resources.
|
|
213
|
+
* This way it will not shared the resource store instance.
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
216
|
+
forkResourceStore?: boolean;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface i18n {
|
|
220
|
+
// Expose parameterized t in the i18next interface hierarchy
|
|
221
|
+
t: TFunction<[DefaultNamespace, ...Exclude<FlatNamespace, DefaultNamespace>[]]>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The default of the i18next module is an i18next instance ready to be initialized by calling init.
|
|
225
|
+
* You can create additional instances using the createInstance function.
|
|
226
|
+
*
|
|
227
|
+
* @param options - Initial options.
|
|
228
|
+
* @param callback - will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
|
229
|
+
*/
|
|
230
|
+
init(callback?: Callback): Promise<TFunction>;
|
|
231
|
+
init<T>(options: InitOptions<T>, callback?: Callback): Promise<TFunction>;
|
|
232
|
+
|
|
233
|
+
loadResources(callback?: (err: any) => void): void;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The use function is there to load additional plugins to i18next.
|
|
237
|
+
* For available module see the plugins page and don't forget to read the documentation of the plugin.
|
|
238
|
+
*
|
|
239
|
+
* @param module Accepts a class or object
|
|
240
|
+
*/
|
|
241
|
+
use<T extends Module>(module: T | NewableModule<T> | Newable<T>): this;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* List of modules used
|
|
245
|
+
*/
|
|
246
|
+
modules: Modules;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Internal container for all used plugins and implementation details like languageUtils, pluralResolvers, etc.
|
|
250
|
+
*/
|
|
251
|
+
services: Services;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Internal container for translation resources
|
|
255
|
+
*/
|
|
256
|
+
store: ResourceStore;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Uses similar args as the t function and returns true if a key exists.
|
|
260
|
+
*/
|
|
261
|
+
exists: ExistsFunction;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Returns a resource data by language.
|
|
265
|
+
*/
|
|
266
|
+
getDataByLanguage(lng: string): { [key: string]: { [key: string]: string } } | undefined;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns a t function that defaults to given language or namespace.
|
|
270
|
+
* Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
|
|
271
|
+
* On the returned function you can like in the t function override the languages or namespaces by passing them in options or by prepending namespace.
|
|
272
|
+
*
|
|
273
|
+
* Accepts optional keyPrefix that will be automatically applied to returned t function.
|
|
274
|
+
*/
|
|
275
|
+
getFixedT<
|
|
276
|
+
Ns extends Namespace | null = DefaultNamespace,
|
|
277
|
+
TKPrefix extends KeyPrefix<ActualNs> = undefined,
|
|
278
|
+
ActualNs extends Namespace = Ns extends null ? DefaultNamespace : Ns,
|
|
279
|
+
>(
|
|
280
|
+
...args:
|
|
281
|
+
| [lng: string | readonly string[], ns?: Ns, keyPrefix?: TKPrefix]
|
|
282
|
+
| [lng: null, ns: Ns, keyPrefix?: TKPrefix]
|
|
283
|
+
): TFunction<ActualNs, TKPrefix>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
|
|
287
|
+
* HINT: For easy testing - setting lng to 'cimode' will set t function to always return the key.
|
|
288
|
+
*/
|
|
289
|
+
changeLanguage(lng?: string, callback?: Callback): Promise<TFunction>;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Is set to the current detected or set language.
|
|
293
|
+
* If you need the primary used language depending on your configuration (supportedLngs, load) you will prefer using i18next.languages[0].
|
|
294
|
+
*/
|
|
295
|
+
language: string;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Is set to an array of language-codes that will be used it order to lookup the translation value.
|
|
299
|
+
*/
|
|
300
|
+
languages: readonly string[];
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Is set to the current resolved language.
|
|
304
|
+
* It can be used as primary used language, for example in a language switcher.
|
|
305
|
+
*/
|
|
306
|
+
resolvedLanguage?: string;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Checks if namespace has loaded yet.
|
|
310
|
+
* i.e. used by react-i18next
|
|
311
|
+
*/
|
|
312
|
+
hasLoadedNamespace(
|
|
313
|
+
ns: string | readonly string[],
|
|
314
|
+
options?: {
|
|
315
|
+
lng?: string | readonly string[];
|
|
316
|
+
precheck: (
|
|
317
|
+
i18n: i18n,
|
|
318
|
+
loadNotPending: (
|
|
319
|
+
lng: string | readonly string[],
|
|
320
|
+
ns: string | readonly string[],
|
|
321
|
+
) => boolean,
|
|
322
|
+
) => boolean;
|
|
323
|
+
},
|
|
324
|
+
): boolean;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Loads additional namespaces not defined in init options.
|
|
328
|
+
*/
|
|
329
|
+
loadNamespaces(ns: string | readonly string[], callback?: Callback): Promise<void>;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Loads additional languages not defined in init options (preload).
|
|
333
|
+
*/
|
|
334
|
+
loadLanguages(lngs: string | readonly string[], callback?: Callback): Promise<void>;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
|
|
338
|
+
*/
|
|
339
|
+
reloadResources(
|
|
340
|
+
lngs?: string | readonly string[],
|
|
341
|
+
ns?: string | readonly string[],
|
|
342
|
+
callback?: () => void,
|
|
343
|
+
): Promise<void>;
|
|
344
|
+
reloadResources(lngs: null, ns: string | readonly string[], callback?: () => void): Promise<void>;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Changes the default namespace.
|
|
348
|
+
*/
|
|
349
|
+
setDefaultNamespace(ns: string): void;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Checks if a namespace has been loaded.
|
|
353
|
+
*/
|
|
354
|
+
hasLoadedNamespace(ns: string, options?: Pick<InitOptions, 'fallbackLng'>): boolean;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Returns rtl or ltr depending on languages read direction.
|
|
358
|
+
*/
|
|
359
|
+
dir(lng?: string): 'ltr' | 'rtl';
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Exposes interpolation.format function added on init.
|
|
363
|
+
*/
|
|
364
|
+
format: FormatFunction;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Will return a new i18next instance.
|
|
368
|
+
* Please read the options page for details on configuration options.
|
|
369
|
+
* Providing a callback will automatically call init.
|
|
370
|
+
* The callback will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
|
371
|
+
*/
|
|
372
|
+
createInstance(options?: InitOptions, callback?: Callback): i18n;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Creates a clone of the current instance. Shares store, plugins and initial configuration.
|
|
376
|
+
* Can be used to create an instance sharing storage but being independent on set language or namespaces.
|
|
377
|
+
*/
|
|
378
|
+
cloneInstance(options?: CloneOptions, callback?: Callback): i18n;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Gets fired after initialization.
|
|
382
|
+
*/
|
|
383
|
+
on(event: 'initialized', callback: (options: InitOptions) => void): void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Gets fired on loaded resources.
|
|
387
|
+
*/
|
|
388
|
+
on(
|
|
389
|
+
event: 'loaded',
|
|
390
|
+
callback: (loaded: { [language: string]: { [namespace: string]: boolean } }) => void,
|
|
391
|
+
): void;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Gets fired if loading resources failed.
|
|
395
|
+
*/
|
|
396
|
+
on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): void;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Gets fired on accessing a key not existing.
|
|
400
|
+
*/
|
|
401
|
+
on(
|
|
402
|
+
event: 'missingKey',
|
|
403
|
+
callback: (lngs: readonly string[], namespace: string, key: string, res: string) => void,
|
|
404
|
+
): void;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Gets fired when resources got added or removed.
|
|
408
|
+
*/
|
|
409
|
+
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Gets fired when changeLanguage got called.
|
|
413
|
+
*/
|
|
414
|
+
on(event: 'languageChanged', callback: (lng: string) => void): void;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Event listener
|
|
418
|
+
*/
|
|
419
|
+
on(event: string, listener: (...args: any[]) => void): void;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Remove event listener
|
|
423
|
+
* removes all callback when callback not specified
|
|
424
|
+
*/
|
|
425
|
+
off(event: string, listener?: (...args: any[]) => void): void;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Gets one value by given key.
|
|
429
|
+
*/
|
|
430
|
+
getResource(
|
|
431
|
+
lng: string,
|
|
432
|
+
ns: string,
|
|
433
|
+
key: string,
|
|
434
|
+
options?: Pick<InitOptions, 'keySeparator' | 'ignoreJSONStructure'>,
|
|
435
|
+
): any;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Adds one key/value.
|
|
439
|
+
*/
|
|
440
|
+
addResource(
|
|
441
|
+
lng: string,
|
|
442
|
+
ns: string,
|
|
443
|
+
key: string,
|
|
444
|
+
value: string,
|
|
445
|
+
options?: { keySeparator?: string; silent?: boolean },
|
|
446
|
+
): i18n;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Adds multiple key/values.
|
|
450
|
+
*/
|
|
451
|
+
addResources(lng: string, ns: string, resources: any): i18n;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Adds a complete bundle.
|
|
455
|
+
* Setting deep param to true will extend existing translations in that file.
|
|
456
|
+
* Setting overwrite to true it will overwrite existing translations in that file.
|
|
457
|
+
*/
|
|
458
|
+
addResourceBundle(
|
|
459
|
+
lng: string,
|
|
460
|
+
ns: string,
|
|
461
|
+
resources: any,
|
|
462
|
+
deep?: boolean,
|
|
463
|
+
overwrite?: boolean,
|
|
464
|
+
): i18n;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Checks if a resource bundle exists.
|
|
468
|
+
*/
|
|
469
|
+
hasResourceBundle(lng: string, ns: string): boolean;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Returns a resource bundle.
|
|
473
|
+
*/
|
|
474
|
+
getResourceBundle(lng: string, ns: string): any;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Removes an existing bundle.
|
|
478
|
+
*/
|
|
479
|
+
removeResourceBundle(lng: string, ns: string): i18n;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Current options
|
|
483
|
+
*/
|
|
484
|
+
options: InitOptions;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Is initialized
|
|
488
|
+
*/
|
|
489
|
+
isInitialized: boolean;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Emit event
|
|
493
|
+
*/
|
|
494
|
+
emit(eventName: string, ...args: any[]): void;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export type * from './typescript/options.d.ts';
|
|
498
|
+
export type {
|
|
499
|
+
// we need to explicitely export some types, to prevent some issues with next-i18next and interpolation variable validation, etc...
|
|
500
|
+
FallbackLngObjList,
|
|
501
|
+
FallbackLng,
|
|
502
|
+
InitOptions,
|
|
503
|
+
TypeOptions,
|
|
504
|
+
CustomTypeOptions,
|
|
505
|
+
CustomPluginOptions,
|
|
506
|
+
PluginOptions,
|
|
507
|
+
FormatFunction,
|
|
508
|
+
InterpolationOptions,
|
|
509
|
+
ReactOptions,
|
|
510
|
+
ResourceKey,
|
|
511
|
+
ResourceLanguage,
|
|
512
|
+
Resource,
|
|
513
|
+
TOptions,
|
|
514
|
+
Namespace,
|
|
515
|
+
DefaultNamespace,
|
|
516
|
+
FlatNamespace,
|
|
517
|
+
} from './typescript/options.d.ts';
|
|
518
|
+
export type * from './typescript/t.d.ts';
|
|
519
|
+
export type {
|
|
520
|
+
TFunction,
|
|
521
|
+
ParseKeys,
|
|
522
|
+
TFunctionReturn,
|
|
523
|
+
TFunctionDetailedResult,
|
|
524
|
+
KeyPrefix,
|
|
525
|
+
} from './typescript/t.d.ts';
|
|
526
|
+
|
|
527
|
+
declare const i18next: i18n;
|
|
528
|
+
export default i18next;
|
|
529
|
+
|
|
530
|
+
export const createInstance: i18n['createInstance'];
|
|
531
|
+
|
|
532
|
+
export const dir: i18n['dir'];
|
|
533
|
+
export const init: i18n['init'];
|
|
534
|
+
export const loadResources: i18n['loadResources'];
|
|
535
|
+
export const reloadResources: i18n['reloadResources'];
|
|
536
|
+
export const use: i18n['use'];
|
|
537
|
+
export const changeLanguage: i18n['changeLanguage'];
|
|
538
|
+
export const getFixedT: i18n['getFixedT'];
|
|
539
|
+
export const t: i18n['t'];
|
|
540
|
+
export const exists: i18n['exists'];
|
|
541
|
+
export const setDefaultNamespace: i18n['setDefaultNamespace'];
|
|
542
|
+
export const hasLoadedNamespace: i18n['hasLoadedNamespace'];
|
|
543
|
+
export const loadNamespaces: i18n['loadNamespaces'];
|
|
544
|
+
export const loadLanguages: i18n['loadLanguages'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18next",
|
|
3
|
-
"version": "23.7.
|
|
3
|
+
"version": "23.7.4",
|
|
4
4
|
"description": "i18next internationalization framework",
|
|
5
5
|
"main": "./dist/cjs/i18next.js",
|
|
6
6
|
"module": "./dist/esm/i18next.js",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"<5.0": {
|
|
10
10
|
"typescript/t.d.ts": [
|
|
11
11
|
"typescript/t.v4.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"index.d.ts": [
|
|
14
|
+
"index.v4.d.ts"
|
|
12
15
|
]
|
|
13
16
|
}
|
|
14
17
|
},
|
|
@@ -115,7 +118,7 @@
|
|
|
115
118
|
"watchify": "4.0.0"
|
|
116
119
|
},
|
|
117
120
|
"scripts": {
|
|
118
|
-
"pretest": "npm run test:typescript && npm run test:typescript:customtypes && npm run test:typescript:defaulttypes && npm run test:typescript:fallbacktypes && npm run test:typescript:noninterop && npm run test:typescript:customcontextseparator",
|
|
121
|
+
"pretest": "npm run generate_ts_v4_index && npm run test:typescript && npm run test:typescript:customtypes && npm run test:typescript:defaulttypes && npm run test:typescript:fallbacktypes && npm run test:typescript:noninterop && npm run test:typescript:customcontextseparator",
|
|
119
122
|
"lint": "eslint src",
|
|
120
123
|
"test": "npm run lint && npm run test:new && npm run test:compat",
|
|
121
124
|
"test:new": "karma start karma.conf.js --singleRun",
|
|
@@ -129,6 +132,7 @@
|
|
|
129
132
|
"tdd": "karma start karma.conf.js",
|
|
130
133
|
"tdd:compat": "karma start karma.backward.conf.js",
|
|
131
134
|
"build": "rimraf dist && rollup -c && echo '{\"type\":\"module\"}' > dist/esm/package.json && cpy \"./dist/umd/*.js\" ./",
|
|
135
|
+
"generate_ts_v4_index": "cp index.d.ts index.v4.d.ts && node -e \"fs.writeFileSync('index.v4.d.ts', fs.readFileSync('index.v4.d.ts').toString().replace(/.js'/g, '.d.ts\\''))\"",
|
|
132
136
|
"fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/esm/package.json",
|
|
133
137
|
"preversion": "npm run test && npm run build && git push",
|
|
134
138
|
"postversion": "npm run fix_dist_package && git push && git push --tags && npm run release",
|
package/typescript/t.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.
|
|
1
|
+
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js';
|
|
2
2
|
import type {
|
|
3
3
|
TypeOptions,
|
|
4
4
|
Namespace,
|
|
5
5
|
FlatNamespace,
|
|
6
6
|
DefaultNamespace,
|
|
7
7
|
TOptions,
|
|
8
|
-
} from './options.
|
|
8
|
+
} from './options.js';
|
|
9
9
|
|
|
10
10
|
type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true;
|
|
11
11
|
type $ValueIfResourcesDefined<Value, Fallback> = $IsResourcesDefined extends true
|
package/typescript/t.v4.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.
|
|
1
|
+
import type { $OmitArrayKeys, $PreservedValue, $Dictionary, $SpecialObject } from './helpers.js';
|
|
2
2
|
import type {
|
|
3
3
|
TypeOptions,
|
|
4
4
|
Namespace,
|
|
5
5
|
FlatNamespace,
|
|
6
6
|
DefaultNamespace,
|
|
7
7
|
TOptions,
|
|
8
|
-
} from './options.
|
|
8
|
+
} from './options.js';
|
|
9
9
|
|
|
10
10
|
type $IsResourcesDefined = [keyof _Resources] extends [never] ? false : true;
|
|
11
11
|
type $ValueIfResourcesDefined<Value, Fallback> = $IsResourcesDefined extends true
|