@o3r/localization
Version:
This module provides a runtime dynamic language/translation support and debug tools.
40 lines • 1.97 kB
TypeScript
import { TranslateLoader } from '@ngx-translate/core';
import { DynamicContentService } from '@o3r/dynamic-content';
import { LoggerService } from '@o3r/logger';
import { Observable } from 'rxjs';
import { LocalizationConfiguration } from '../core';
import * as i0 from "@angular/core";
/**
* This class is responsible for loading translation bundles from remote or local endpoints depending on the LocalizationConfiguration.
* Fallback mechanism ensures that if a bundle in some language cannot be fetched remotely
* we try to fetch the same language bundle locally (bundles stored inside the application)
* and finally load the fallback language bundle (if all previous fetches failed)
*/
export declare class TranslationsLoader implements TranslateLoader {
private readonly localizationConfiguration;
private readonly logger?;
private readonly dynamicContentService?;
constructor(localizationConfiguration: LocalizationConfiguration, logger?: LoggerService | undefined, dynamicContentService?: DynamicContentService | undefined);
/**
* Download a language bundle file
* @param url Url to the bundle file
*/
private downloadLanguageBundle$;
/**
* @inheritdoc
*/
getTranslation(lang: string): Observable<any>;
/**
*
*Fetches localization bundles from published folder (internal to application)
*
*1. try to load lang from local
*2. if 1 fails try to load fallback lang but only if it's different from lang in 1
* @param lang - language of the bundle
* @param fallbackLanguage - fallback language in case bundle in language not found
*/
getTranslationFromLocal(lang: string, fallbackLanguage: string): Observable<any>;
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationsLoader, [null, { optional: true; }, { optional: true; }]>;
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationsLoader>;
}
//# sourceMappingURL=translations-loader.d.ts.map