Angular2+国际化方案(ngx(2)

/** * Sets the default language to use as a fallback * @param lang */ setDefaultLang(lang: string): void; /** * Gets the default language used * @returns string */ getDefaultLang(): string; /** * Changes the lang currently used * @param lang * @returns {Observable<*>} */ use(lang: string): Observable<any>; /** * Gets an object of translations for a given language with the current loader * and passes it through the compiler * @param lang * @returns {Observable<*>} */ getTranslation(lang: string): Observable<any>; /** * Manually sets an object of translations for a given language * after passing it through the compiler * @param lang * @param translations * @param shouldMerge */ setTranslation(lang: string, translations: Object, shouldMerge?: boolean): void; /** * Returns an array of currently available langs * @returns {any} */ getLangs(): Array<string>; /** * @param langs * Add available langs */ addLangs(langs: Array<string>): void; /** * Returns the parsed result of the translations * @param translations * @param key * @param interpolateParams * @returns {any} */ getParsedResult(translations: any, key: any, interpolateParams?: Object): any; /** * Gets the translated value of a key (or an array of keys) * @param key * @param interpolateParams * @returns {any} the translated key, or an object of translated keys */ get(key: string | Array<string>, interpolateParams?: Object): Observable<string | any>; /** * Returns a stream of translated values of a key (or an array of keys) which updates * whenever the language changes. * @param key * @param interpolateParams * @returns {any} A stream of the translated key, or an object of translated keys */ stream(key: string | Array<string>, interpolateParams?: Object): Observable<string | any>; /** * Returns a translation instantly from the internal state of loaded translation. * All rules regarding the current language, the preferred language of even fallback languages will be used except any promise handling. * @param key * @param interpolateParams * @returns {string} */ instant(key: string | Array<string>, interpolateParams?: Object): string | any; /** * Sets the translated value of a key, after compiling it * @param key * @param value * @param lang */ set(key: string, value: string, lang?: string): void; /** * Allows to reload the lang file from the file * @param lang * @returns {Observable<any>} */ reloadLang(lang: string): Observable<any>; /** * Deletes inner translation * @param lang */ resetLang(lang: string): void; /** * Returns the language code name from the browser, e.g. "de" * * @returns string */ getBrowserLang(): string; /** * Returns the culture language code name from the browser, e.g. "de-DE" * * @returns string */ getBrowserCultureLang(): string;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wygpsf.html