46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { EntityDict } from 'oak-domain/lib/types';
|
||
import { Feature } from '../types/Feature';
|
||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||
import { Cache } from './cache';
|
||
import { LocalStorage } from './localStorage';
|
||
import { Environment } from './environment';
|
||
import { Scope, TranslateOptions } from 'i18n-js';
|
||
export declare class Locales<ED extends EntityDict & BaseEntityDict> extends Feature {
|
||
static REFRESH_STALE_INTERVAL: number;
|
||
private cache;
|
||
private localStorage;
|
||
private environment;
|
||
private language;
|
||
private defaultLng;
|
||
private i18n;
|
||
private initializeLng;
|
||
constructor(cache: Cache<ED>, localStorage: LocalStorage, environment: Environment, defaultLng: string);
|
||
private detectLanguage;
|
||
private reloadDataset;
|
||
loadServerData(nss: string[]): Promise<void>;
|
||
/**
|
||
* 当发生key缺失时,向服务器请求最新的i18n数据,对i18n缓存数据的行为优化放在cache中统一进行
|
||
* @param ns
|
||
*/
|
||
private loadData;
|
||
/**
|
||
* 暴露给小程序的Wxs调用
|
||
* @param key
|
||
*/
|
||
loadMissedLocale(key: string): void;
|
||
/**
|
||
* translate函数,这里编译器会在params里注入两个参数 #oakNamespace 和 #oakModule,用以标识文件路径
|
||
* @param key
|
||
* @param params
|
||
* @returns
|
||
*/
|
||
t(key: string, params?: TranslateOptions): string;
|
||
getState(): {
|
||
lng: string;
|
||
defaultLng: string;
|
||
dataset: import("i18n-js").Dict;
|
||
version: number;
|
||
};
|
||
hasKey(key: Scope, params?: TranslateOptions): string;
|
||
}
|