@senspark/ee
Version:
utility library for cocos creator
49 lines (48 loc) • 1.58 kB
TypeScript
import * as Polyglot from 'node-polyglot';
import { ObserverManager } from './ObserverManager';
declare type Observer = () => void;
export declare class LanguageManager extends ObserverManager<Observer> {
private static sharedInstance?;
/** Gets the singleton. */
static getInstance(): LanguageManager;
/**
* Current config directory.
* Actually UUID in editor mode and relative path in release mode.
*/
private configDir?;
/** Current active language. */
private currentLanguage?;
private configs;
/** Wrappee i18n manager. */
private polyglot;
private constructor();
/**
* Gets all available languages.
* @return Array of language names.
*/
getLanguages(): string[];
/**
* Gets the config dir.
* Used in editor only.
*/
getConfigDir(): string | undefined;
/**
* Sets the config directory.
* @param path The directory path.
*/
setConfigDir(path: string): void;
/** Clears the language directory. */
resetConfigDir(): void;
private updateConfigs;
private updateLanguage;
/** Gets the active language. */
getCurrentLanguage(): string | undefined;
/** Sets the active language. */
setCurrentLanguage(language: string | undefined): void;
/** Gets the language format in the current language. */
getFormat(key: string): string | undefined;
parseFormat(key: string, options?: Polyglot.InterpolationOptions): string | undefined;
/** Detects language for the config path. */
private parseLanguage;
}
export {};