UNPKG

ng-dynamic-mf

Version:

[![npm](https://img.shields.io/npm/v/ng-dynamic-mf?color=%2300d26a&style=for-the-badge)](https://www.npmjs.com/package/ng-dynamic-mf) [![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/LoaderB0T_ng-dynamic-mf?server=https%3A%2F%2Fsonarcloud

77 lines (76 loc) 3.98 kB
import { Observable } from 'rxjs'; import { TranslationResolver, TranslationResolverMultiLocale, TranslationResolverSet } from './translation-resolver.type'; import * as i0 from "@angular/core"; /** * This service is used to dynamically load translations from different modules. * It uses @ngx-translate/core internally, so make sure you have it installed and * the TranslateModule is imported correctly. */ export declare class DynamicTranslationService { private readonly _translateService; private readonly _translationsInvalidated; private readonly _translationsUpdated; private readonly _translationStore; private _locale; private _debugMode; constructor(); /** * Sets the debug mode. In debug mode, the translation values are replaced with their keys. * @param debugMode Whether to enable debug mode */ setDebugMode(debugMode: boolean): void; /** * Registers a resolver for translations for a specific locale. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @param locale The locale of the translations * @param translationResolver The resolver for the translations */ registerTranslationSetForLocale(translationSetIdentifier: string, locale: string, translationResolver: TranslationResolver): void; /** * Registers resolvers for translations for multiple locales. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @param translationResolvers The resolvers for the translations */ registerTranslationSet(translationSetIdentifier: string, translationResolvers: TranslationResolverMultiLocale): void; /** * Registers multiple translation resolvers for multiple locales. * @param set The set of resolvers for the translations */ registerMultipleTranslationSets(set: TranslationResolverSet): void; private doRegisterTranslationSet; private registerSingleTranslation; /** * Removes a translation set for a specific locale. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @param locale The locale of the translations. If not specified, the translations will be removed for all locales. */ removeTranslation(translationSetIdentifier: string, locale?: string): void; /** * Asynchronously checks if a translation set is loaded for the current locale. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @returns Observable that emits true if the translation set is loaded, false otherwise */ isTranslationSetLoaded(translationSetIdentifier: string): Observable<boolean>; /** * Resolves if a translation set is loaded for the current locale. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @returns Promise that resolves if the translation set is loaded, never rejects (use isTranslationSetLoaded() to check if the translation set is loaded) */ ensureTranslationSetIsLoaded(translationSetIdentifier: string): Promise<void>; /** * Checks if a translation set is loaded for the current locale. * @param translationSetIdentifier The identifier of the translations (e.g. the name of the module) * @returns true if the translation set is loaded, false otherwise */ isTranslationSetLoadedSync(translationSetIdentifier: string): boolean; private doRemoveTranslation; private invalidateTranslations; private loadTranslations; private resolveTranslations; private mergeLoadedTranslations; private resolveTranslation; private loadLocaleFromAssetPath; private putTranslationsIntoDebugMode; static ɵfac: i0.ɵɵFactoryDeclaration<DynamicTranslationService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DynamicTranslationService>; }