@react-native-localize-ext/core
Version:
make i18n in react-native much smoother
44 lines (43 loc) • 1.82 kB
TypeScript
interface Language<T> {
key: string;
values: T;
}
export interface UnListen {
(): void;
}
export interface I18nConfig<T> {
defaultLocale: Language<T>;
loader?: (localName: string) => Promise<any>;
}
export declare class I18n<U extends object = object, T = object> {
protected readonly defaultLocale: U;
protected readonly loader: I18nConfig<U>['loader'];
protected locales: Partial<Record<string, U>>;
protected hashes: Partial<Record<string, string>>;
protected current: U;
protected loadings: string[];
protected currentName: string;
protected listeners: ((localeName: string) => void)[];
protected caches: Partial<Record<string, any>>;
private static CACHE_ROOT_KEY;
constructor(config: I18nConfig<U>);
define(localeName: string, values: U): this;
getLocaleName(): string;
locale(name: string): Promise<void>;
listen(fn: (localeName: string) => void): UnListen;
t(key: string): any;
chain(): T;
protected proxy(data: object, allProperties: string[], useDefaultLocal: boolean): object;
protected createProxy(data: object, allProperties: string[], useDefaultLocal: boolean): object;
protected getProxyData(target: object, allProperties: string[], property: string, useDefaultLocal: boolean): any;
protected recursiveDefaultData(allProperties: string[]): U;
protected notFound(properties: string | string[]): string;
protected isValidProperty(property: string | number | symbol): property is string;
protected isValidLocale(locale: U): boolean;
protected isLoading(name: string): boolean;
protected canPublishFromLoader(name: string): boolean;
protected removeLoading(name: string): void;
protected clearLoading(): void;
protected publish(name: string, values: U): void;
}
export {};