"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "index.d.ts" between
i18next-20.3.3.tar.gz and i18next-20.3.4.tar.gz

About: i18next is an internationalization framework for browser or any other javascript environment.

index.d.ts  (i18next-20.3.3):index.d.ts  (i18next-20.3.4)
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type MergeBy<T, K> = Omit<T, keyof K> & K; type MergeBy<T, K> = Omit<T, keyof K> & K;
export interface FallbackLngObjList { export interface FallbackLngObjList {
[language: string]: string[]; [language: string]: readonly string[];
} }
export type FallbackLng = export type FallbackLng =
| string | string
| string[] | readonly string[]
| FallbackLngObjList | FallbackLngObjList
| ((code: string) => string | string[] | FallbackLngObjList); | ((code: string) => string | readonly string[] | FallbackLngObjList);
export type FormatFunction = ( export type FormatFunction = (
value: any, value: any,
format?: string, format?: string,
lng?: string, lng?: string,
options?: InterpolationOptions & { [key: string]: any }, options?: InterpolationOptions & { [key: string]: any },
) => string; ) => string;
export interface InterpolationOptions { export interface InterpolationOptions {
/** /**
skipping to change at line 181 skipping to change at line 181
hashTransKey?(defaultValue: TOptionsBase['defaultValue']): TOptionsBase['defau ltValue']; hashTransKey?(defaultValue: TOptionsBase['defaultValue']): TOptionsBase['defau ltValue'];
/** /**
* Convert eg. <br/> found in translations to a react component of type br * Convert eg. <br/> found in translations to a react component of type br
* @default true * @default true
*/ */
transSupportBasicHtmlNodes?: boolean; transSupportBasicHtmlNodes?: boolean;
/** /**
* Which nodes not to convert in defaultValue generation in the Trans componen t. * Which nodes not to convert in defaultValue generation in the Trans componen t.
* @default ['br', 'strong', 'i', 'p'] * @default ['br', 'strong', 'i', 'p']
*/ */
transKeepBasicHtmlNodesFor?: string[]; transKeepBasicHtmlNodesFor?: readonly string[];
/** /**
* Wrap text nodes in a user-specified element. * Wrap text nodes in a user-specified element.
* @default '' * @default ''
*/ */
transWrapTextNodes?: string; transWrapTextNodes?: string;
} }
/** /**
* This interface can be augmented by users to add types to `i18next` default Pl uginOptions. * This interface can be augmented by users to add types to `i18next` default Pl uginOptions.
*/ */
skipping to change at line 255 skipping to change at line 255
/** /**
* Language to use if translations in user language are not available. * Language to use if translations in user language are not available.
* @default 'dev' * @default 'dev'
*/ */
fallbackLng?: false | FallbackLng; fallbackLng?: false | FallbackLng;
/** /**
* DEPRECATED use supportedLngs * DEPRECATED use supportedLngs
* @default false * @default false
*/ */
whitelist?: false | string[]; whitelist?: false | readonly string[];
/** /**
* DEPRECTADED use nonExplicitSupportedLngs * DEPRECTADED use nonExplicitSupportedLngs
* @default false * @default false
*/ */
nonExplicitWhitelist?: boolean; nonExplicitWhitelist?: boolean;
/** /**
* Array of allowed languages * Array of allowed languages
* @default false * @default false
*/ */
supportedLngs?: false | string[]; supportedLngs?: false | readonly string[];
/** /**
* If true will pass eg. en-US if finding en in supportedLngs * If true will pass eg. en-US if finding en in supportedLngs
* @default false * @default false
*/ */
nonExplicitSupportedLngs?: boolean; nonExplicitSupportedLngs?: boolean;
/** /**
* Language codes to lookup, given set language is * Language codes to lookup, given set language is
* 'en-US': 'all' --> ['en-US', 'en', 'dev'], * 'en-US': 'all' --> ['en-US', 'en', 'dev'],
* 'currentOnly' --> 'en-US', * 'currentOnly' --> 'en-US',
* 'languageOnly' --> 'en' * 'languageOnly' --> 'en'
* @default 'all' * @default 'all'
*/ */
load?: 'all' | 'currentOnly' | 'languageOnly'; load?: 'all' | 'currentOnly' | 'languageOnly';
/** /**
* Array of languages to preload. Important on server-side to assert translati ons are loaded before rendering views. * Array of languages to preload. Important on server-side to assert translati ons are loaded before rendering views.
* @default false * @default false
*/ */
preload?: false | string[]; preload?: false | readonly string[];
/** /**
* Language will be lowercased eg. en-US --> en-us * Language will be lowercased eg. en-US --> en-us
* @default false * @default false
*/ */
lowerCaseLng?: boolean; lowerCaseLng?: boolean;
/** /**
* Language will be lowercased EN --> en while leaving full locales like en-US * Language will be lowercased EN --> en while leaving full locales like en-US
* @default false * @default false
*/ */
cleanCode?: boolean; cleanCode?: boolean;
/** /**
* String or array of namespaces to load * String or array of namespaces to load
* @default 'translation' * @default 'translation'
*/ */
ns?: string | string[]; ns?: string | readonly string[];
/** /**
* Default namespace used if not passed to translation function * Default namespace used if not passed to translation function
* @default 'translation' * @default 'translation'
*/ */
defaultNS?: string; defaultNS?: string;
/** /**
* String or array of namespaces to lookup key if not found in given namespace . * String or array of namespaces to lookup key if not found in given namespace .
* @default false * @default false
*/ */
fallbackNS?: false | string | string[]; fallbackNS?: false | string | readonly string[];
/** /**
* Calls save missing key function on backend if key not found * Calls save missing key function on backend if key not found
* @default false * @default false
*/ */
saveMissing?: boolean; saveMissing?: boolean;
/** /**
* Experimental: enable to update default values using the saveMissing * Experimental: enable to update default values using the saveMissing
* (Works only if defaultValue different from translated value. * (Works only if defaultValue different from translated value.
skipping to change at line 346 skipping to change at line 346
* @default 'fallback' * @default 'fallback'
*/ */
saveMissingTo?: 'current' | 'all' | 'fallback'; saveMissingTo?: 'current' | 'all' | 'fallback';
/** /**
* Used for custom missing key handling (needs saveMissing set to true!) * Used for custom missing key handling (needs saveMissing set to true!)
* @default false * @default false
*/ */
missingKeyHandler?: missingKeyHandler?:
| false | false
| ((lngs: string[], ns: string, key: string, fallbackValue: string) => void) ; | ((lngs: readonly string[], ns: string, key: string, fallbackValue: string) => void);
/** /**
* Receives a key that was not found in `t()` and returns a value, that will b e returned by `t()` * Receives a key that was not found in `t()` and returns a value, that will b e returned by `t()`
* @default noop * @default noop
*/ */
parseMissingKeyHandler?(key: string): any; parseMissingKeyHandler?(key: string): any;
/** /**
* Appends namespace to missing key * Appends namespace to missing key
* @default false * @default false
skipping to change at line 376 skipping to change at line 376
/** /**
* Will use 'plural' as suffix for languages only having 1 plural form, settin g it to false will suffix all with numbers * Will use 'plural' as suffix for languages only having 1 plural form, settin g it to false will suffix all with numbers
* @default true * @default true
*/ */
simplifyPluralSuffix?: boolean; simplifyPluralSuffix?: boolean;
/** /**
* String or array of postProcessors to apply per default * String or array of postProcessors to apply per default
* @default false * @default false
*/ */
postProcess?: false | string | string[]; postProcess?: false | string | readonly string[];
/** /**
* passthrough the resolved object including 'usedNS', 'usedLang' etc into opt ions object of postprocessors as 'i18nResolved' property * passthrough the resolved object including 'usedNS', 'usedLang' etc into opt ions object of postprocessors as 'i18nResolved' property
* @default false * @default false
*/ */
postProcessPassResolved?: boolean; postProcessPassResolved?: boolean;
/** /**
* Allows null values as valid translation * Allows null values as valid translation
* @default true * @default true
skipping to change at line 550 skipping to change at line 550
* Styles to adapt layout in iframe mode to your website layout. * Styles to adapt layout in iframe mode to your website layout.
* This will add a style to `<body>` * This will add a style to `<body>`
* @default 'margin-right: 605px;' * @default 'margin-right: 605px;'
*/ */
bodyStyle?: string; bodyStyle?: string;
/** /**
* Handle when locize saved the edited translations, eg. reload website * Handle when locize saved the edited translations, eg. reload website
* @default noop * @default noop
*/ */
onEditorSaved?: (lng: null, ns: string | string[]) => void; onEditorSaved?: (lng: null, ns: string | readonly string[]) => void;
}; };
/** /**
* Options for https://github.com/locize/locize-lastused * Options for https://github.com/locize/locize-lastused
* @default undefined * @default undefined
*/ */
locizeLastUsed?: { locizeLastUsed?: {
/** /**
* The id of your locize project * The id of your locize project
*/ */
skipping to change at line 591 skipping to change at line 591
* Debounce interval to send data in milliseconds * Debounce interval to send data in milliseconds
* @default 90000 * @default 90000
*/ */
debounceSubmit?: number; debounceSubmit?: number;
/** /**
* Hostnames that are allowed to send last used data. * Hostnames that are allowed to send last used data.
* Please keep those to your local system, staging, test servers (not produc tion) * Please keep those to your local system, staging, test servers (not produc tion)
* @default ['localhost'] * @default ['localhost']
*/ */
allowedHosts?: string[]; allowedHosts?: readonly string[];
}; };
/** /**
* Automatically lookup for a flat key if a nested key is not found an vice-ve rsa * Automatically lookup for a flat key if a nested key is not found an vice-ve rsa
* @default true * @default true
*/ */
ignoreJSONStructure?: boolean; ignoreJSONStructure?: boolean;
} }
export interface TOptionsBase { export interface TOptionsBase {
skipping to change at line 625 skipping to change at line 625
* Object with vars for interpolation - or put them directly in options * Object with vars for interpolation - or put them directly in options
*/ */
replace?: any; replace?: any;
/** /**
* Override language to use * Override language to use
*/ */
lng?: string; lng?: string;
/** /**
* Override languages to use * Override languages to use
*/ */
lngs?: string[]; lngs?: readonly string[];
/** /**
* Override language to lookup key if not found see fallbacks for details * Override language to lookup key if not found see fallbacks for details
*/ */
fallbackLng?: FallbackLng; fallbackLng?: FallbackLng;
/** /**
* Override namespaces (string or array) * Override namespaces (string or array)
*/ */
ns?: string | string[]; ns?: string | readonly string[];
/** /**
* Override char to separate keys * Override char to separate keys
*/ */
keySeparator?: false | string; keySeparator?: false | string;
/** /**
* Override char to split namespace from key * Override char to split namespace from key
*/ */
nsSeparator?: false | string; nsSeparator?: false | string;
/** /**
* Accessing an object not a translation string (can be set globally too) * Accessing an object not a translation string (can be set globally too)
*/ */
returnObjects?: boolean; returnObjects?: boolean;
/** /**
* Char, eg. '\n' that arrays will be joined by (can be set globally too) * Char, eg. '\n' that arrays will be joined by (can be set globally too)
*/ */
joinArrays?: string; joinArrays?: string;
/** /**
* String or array of postProcessors to apply see interval plurals as a sample * String or array of postProcessors to apply see interval plurals as a sample
*/ */
postProcess?: string | string[]; postProcess?: string | readonly string[];
/** /**
* Override interpolation options * Override interpolation options
*/ */
interpolation?: InterpolationOptions; interpolation?: InterpolationOptions;
} }
/** /**
* indexer that is open to any value * indexer that is open to any value
*/ */
export type StringMap = { [key: string]: any }; export type StringMap = { [key: string]: any };
skipping to change at line 783 skipping to change at line 783
/** /**
* Used to load data for i18next. * Used to load data for i18next.
* Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next). * Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next).
* For singleton set property `type` to `'backend'` For a prototype constructor set static property. * For singleton set property `type` to `'backend'` For a prototype constructor set static property.
*/ */
export interface BackendModule<TOptions = object> extends Module { export interface BackendModule<TOptions = object> extends Module {
type: 'backend'; type: 'backend';
init(services: Services, backendOptions: TOptions, i18nextOptions: InitOptions ): void; init(services: Services, backendOptions: TOptions, i18nextOptions: InitOptions ): void;
read(language: string, namespace: string, callback: ReadCallback): void; read(language: string, namespace: string, callback: ReadCallback): void;
/** Save the missing translation */ /** Save the missing translation */
create?(languages: string[], namespace: string, key: string, fallbackValue: st create?(
ring): void; languages: readonly string[],
namespace: string,
key: string,
fallbackValue: string,
): void;
/** Load multiple languages and namespaces. For backends supporting multiple r esources loading */ /** Load multiple languages and namespaces. For backends supporting multiple r esources loading */
readMulti?(languages: string[], namespaces: string[], callback: MultiReadCallb readMulti?(
ack): void; languages: readonly string[],
namespaces: readonly string[],
callback: MultiReadCallback,
): void;
/** Store the translation. For backends acting as cache layer */ /** Store the translation. For backends acting as cache layer */
save?(language: string, namespace: string, data: ResourceLanguage): void; save?(language: string, namespace: string, data: ResourceLanguage): void;
} }
/** /**
* Used to detect language in user land. * Used to detect language in user land.
* Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next). * Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next).
* For singleton set property `type` to `'languageDetector'` For a prototype con structor set static property. * For singleton set property `type` to `'languageDetector'` For a prototype con structor set static property.
*/ */
export interface LanguageDetectorModule extends Module { export interface LanguageDetectorModule extends Module {
type: 'languageDetector'; type: 'languageDetector';
init(services: Services, detectorOptions: object, i18nextOptions: InitOptions) : void; init(services: Services, detectorOptions: object, i18nextOptions: InitOptions) : void;
/** Must return detected language */ /** Must return detected language */
detect(): string | string[] | undefined; detect(): string | readonly string[] | undefined;
cacheUserLanguage(lng: string): void; cacheUserLanguage(lng: string): void;
} }
/** /**
* Used to detect language in user land. * Used to detect language in user land.
* Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next). * Can be provided as a singleton or as a prototype constructor (preferred for s upporting multiple instances of i18next).
* For singleton set property `type` to `'languageDetector'` For a prototype con structor set static property. * For singleton set property `type` to `'languageDetector'` For a prototype con structor set static property.
*/ */
export interface LanguageDetectorAsyncModule extends Module { export interface LanguageDetectorAsyncModule extends Module {
type: 'languageDetector'; type: 'languageDetector';
/** Set to true to enable async detection */ /** Set to true to enable async detection */
async: true; async: true;
init(services: Services, detectorOptions: object, i18nextOptions: InitOptions) : void; init(services: Services, detectorOptions: object, i18nextOptions: InitOptions) : void;
/** Must call callback passing detected language */ /** Must call callback passing detected language */
detect(callback: (lng: string | string[] | undefined) => void): void; detect(callback: (lng: string | readonly string[] | undefined) => void): void;
cacheUserLanguage(lng: string): void; cacheUserLanguage(lng: string): void;
} }
/** /**
* Used to extend or manipulate the translated values before returning them in ` t` function. * Used to extend or manipulate the translated values before returning them in ` t` function.
* Need to be a singleton object. * Need to be a singleton object.
*/ */
export interface PostProcessorModule extends Module { export interface PostProcessorModule extends Module {
/** Unique name */ /** Unique name */
name: string; name: string;
skipping to change at line 916 skipping to change at line 925
/** /**
* Returns a resource data by language. * Returns a resource data by language.
*/ */
getDataByLanguage(lng: string): { translation: { [key: string]: string } } | u ndefined; getDataByLanguage(lng: string): { translation: { [key: string]: string } } | u ndefined;
/** /**
* Returns a t function that defaults to given language or namespace. * Returns a t function that defaults to given language or namespace.
* Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case. * Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
* On the returned function you can like in the t function override the langua ges or namespaces by passing them in options or by prepending namespace. * On the returned function you can like in the t function override the langua ges or namespaces by passing them in options or by prepending namespace.
*/ */
getFixedT(lng: string | string[], ns?: string | string[]): TFunction; getFixedT(lng: string | readonly string[], ns?: string | readonly string[]): T
getFixedT(lng: null, ns: string | string[]): TFunction; Function;
getFixedT(lng: null, ns: string | readonly string[]): TFunction;
/** /**
* Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading. * Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
* HINT: For easy testing - setting lng to 'cimode' will set t function to alw ays return the key. * HINT: For easy testing - setting lng to 'cimode' will set t function to alw ays return the key.
*/ */
changeLanguage(lng?: string, callback?: Callback): Promise<TFunction>; changeLanguage(lng?: string, callback?: Callback): Promise<TFunction>;
/** /**
* Is set to the current detected or set language. * Is set to the current detected or set language.
* If you need the primary used language depending on your configuration (supp ortedLngs, load) you will prefer using i18next.languages[0]. * If you need the primary used language depending on your configuration (supp ortedLngs, load) you will prefer using i18next.languages[0].
*/ */
language: string; language: string;
/** /**
* Is set to an array of language-codes that will be used it order to lookup t he translation value. * Is set to an array of language-codes that will be used it order to lookup t he translation value.
*/ */
languages: string[]; languages: readonly string[];
/** /**
* Loads additional namespaces not defined in init options. * Loads additional namespaces not defined in init options.
*/ */
loadNamespaces(ns: string | string[], callback?: Callback): Promise<void>; loadNamespaces(ns: string | readonly string[], callback?: Callback): Promise<v oid>;
/** /**
* Loads additional languages not defined in init options (preload). * Loads additional languages not defined in init options (preload).
*/ */
loadLanguages(lngs: string | string[], callback?: Callback): Promise<void>; loadLanguages(lngs: string | readonly string[], callback?: Callback): Promise< void>;
/** /**
* Reloads resources on given state. Optionally you can pass an array of langu ages and namespaces as params if you don't want to reload all. * Reloads resources on given state. Optionally you can pass an array of langu ages and namespaces as params if you don't want to reload all.
*/ */
reloadResources( reloadResources(
lngs?: string | string[], lngs?: string | readonly string[],
ns?: string | string[], ns?: string | readonly string[],
callback?: () => void, callback?: () => void,
): Promise<void>; ): Promise<void>;
reloadResources(lngs: null, ns: string | string[], callback?: () => void): Pro mise<void>; reloadResources(lngs: null, ns: string | readonly string[], callback?: () => v oid): Promise<void>;
/** /**
* Changes the default namespace. * Changes the default namespace.
*/ */
setDefaultNamespace(ns: string): void; setDefaultNamespace(ns: string): void;
/** /**
* Returns rtl or ltr depending on languages read direction. * Returns rtl or ltr depending on languages read direction.
*/ */
dir(lng?: string): 'ltr' | 'rtl'; dir(lng?: string): 'ltr' | 'rtl';
skipping to change at line 1005 skipping to change at line 1014
/** /**
* Gets fired if loading resources failed. * Gets fired if loading resources failed.
*/ */
on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): void; on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): void;
/** /**
* Gets fired on accessing a key not existing. * Gets fired on accessing a key not existing.
*/ */
on( on(
event: 'missingKey', event: 'missingKey',
callback: (lngs: string[], namespace: string, key: string, res: string) => v oid, callback: (lngs: readonly string[], namespace: string, key: string, res: str ing) => void,
): void; ): void;
/** /**
* Gets fired when resources got added or removed. * Gets fired when resources got added or removed.
*/ */
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): v oid; on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): v oid;
/** /**
* Gets fired when changeLanguage got called. * Gets fired when changeLanguage got called.
*/ */
 End of changes. 27 change blocks. 
31 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)