@o3r/localization
Version:
This module provides a runtime dynamic language/translation support and debug tools.
796 lines (765 loc) • 34.3 kB
TypeScript
import { Translation, DevtoolsCommonOptions, ContextualizationDevtoolsCommonOptions, OtterMessageContent, MessageDataTypes, ConnectContentMessage, RequestMessagesContentMessage, DevtoolsServiceInterface, SetStateActionPayload, Serializer } from '@o3r/core';
export { Translation } from '@o3r/core';
import * as i0 from '@angular/core';
import { InjectionToken, PipeTransform, OnDestroy, ChangeDetectorRef, ModuleWithProviders, FactoryProvider } from '@angular/core';
import * as i6 from '@ngx-translate/core';
import { TranslateCompiler, TranslateService, TranslatePipe, TranslateDirective, TranslateLoader } from '@ngx-translate/core';
import { Options } from 'intl-messageformat';
import { Subscription, Observable } from 'rxjs';
import * as i9 from '@angular/common';
import { DatePipe, DecimalPipe, CurrencyPipe } from '@angular/common';
import * as i7 from '@angular/cdk/bidi';
import { Directionality, Direction } from '@angular/cdk/bidi';
import * as i8 from '@o3r/dynamic-content';
import { DynamicContentService } from '@o3r/dynamic-content';
import * as _ngrx_store from '@ngrx/store';
import { ActionReducer, Action, ReducerTypes, ActionCreator } from '@ngrx/store';
import { LoggerService } from '@o3r/logger';
/**
* Decorator to pass localization url
* @param _url
*/
declare function Localization(_url: string): (target: any, key: string) => void;
/** Object mapping of a localized string */
interface JSONLocalization {
/** The key of the localized string. */
key: string;
/** The description of the key used to give some context to the translators. */
description: string;
/** True means that the key will be mapped to a dictionary in the CMS. */
dictionary: boolean;
/** True means that the value has to be overriden in the CMS. */
referenceData: boolean;
/** Tags used to filter/categorize localization strings */
tags?: string[];
/** The default value for EN language. It is mandatory if dictionary is set to false. */
value?: string;
/** Reference to another key. */
ref?: string;
}
/** Localization Metadata file structure */
type LocalizationMetadata = JSONLocalization[];
/**
* Describes configuration for LocalizationModule
*/
interface LocalizationConfiguration {
/** List of available languages */
supportedLocales: string[];
/** Application display language */
language?: string;
/** Url to fetch translation bundles from */
endPointUrl: string;
/** Prefix endPoinrUrl with dynamicContentPath provided by DynamicContentPath */
useDynamicContent: boolean;
/** List of RTL language codes */
rtlLanguages: string[];
/**
* Fallback language map of resource in case translation in language does not exist.
* translate to unsupported language will try to map to supportedLocales from below property.
* @example
* ```typescript
* {
* supportedLocales: ['en-GB', 'en-US', 'fr-FR'],
* fallbackLocalesMap: {'en-CA': 'en-US', 'de': 'fr-FR'}
* }
* // translate to en-CA -> fallback to en-US, translate to de-DE -> fallback to fr-FR,
* // translate to en-NZ -> fallback to en-GB, translate to en -> fallback to en-GB.
* ```
*/
fallbackLocalesMap?: {
[supportedLocale: string]: string;
};
/** Fallback language of resource in case translation in language does not exist */
fallbackLanguage: string;
/** Path relative to published folder where webpack will copy translation bundles */
bundlesOutputPath: string;
/** Debug mode switch */
debugMode: boolean;
/** Query parameters for fetching the localization resources */
queryParams?: {
[key: string]: string;
};
/** Fetch options object as per https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters */
fetchOptions?: RequestInit;
/** Enable the ability to switch the translations on and off at runtime. */
enableTranslationDeactivation: boolean;
/**
* Merge the translations from DynamicContentPath with the local translations
* Warning: Enable this option will download two localization bundles and can delay the display of the text on application first page
* @default false
*/
mergeWithLocalTranslations: boolean;
}
/**
* Default configuration for LocalizationModule
*/
declare const DEFAULT_LOCALIZATION_CONFIGURATION: Readonly<LocalizationConfiguration>;
/**
* Translatable item
*/
interface Translatable<T extends Translation> {
/**
* translations map
*/
translations: T;
}
/**
* Options for Lazy Message Format compiler
*/
interface LazyMessageFormatConfig extends Options {
/**
* Enables compiled translation caching
* @default true
*/
enableCache?: boolean;
/**
* Enables HTML in translation
* @default true
*/
ignoreTag?: boolean;
}
/**
* Message format configuration default value
*/
declare const lazyMessageDefaultConfig: Readonly<LazyMessageFormatConfig>;
/** Message Format configuration Token */
declare const MESSAGE_FORMAT_CONFIG: InjectionToken<LazyMessageFormatConfig>;
/**
* This compiler expects ICU syntax and compiles the expressions with messageformat.js
* Compare to ngx-translate-messageformat-compiler package, the compilation of the translation is done only on demand
*/
declare class TranslateMessageFormatLazyCompiler extends TranslateCompiler {
/** Configuration */
private readonly config;
/** Cache of compiled translations */
private cache;
constructor();
/**
* Clear the cache of the compiled translations
*/
clearCache(): void;
/** @inheritDoc */
compile(value: string, lang: string): (params: any) => string;
/** @inheritDoc */
compileTranslations(translations: {
[x: string]: any;
}, lang: string): {
[x: string]: (params: any) => string;
};
static ɵfac: i0.ɵɵFactoryDeclaration<TranslateMessageFormatLazyCompiler, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TranslateMessageFormatLazyCompiler>;
}
interface LocalizationDevtoolsServiceOptions extends DevtoolsCommonOptions, ContextualizationDevtoolsCommonOptions {
metadataFilePath: string;
}
/** Localizations message content */
interface LocalizationsContentMessage extends OtterMessageContent<'localizations'> {
/** Localizations metadata */
localizations: LocalizationMetadata;
}
/** Languages message content */
interface LanguagesContentMessage extends OtterMessageContent<'languages'> {
/** Languages available */
languages: string[];
}
/** Switch languages message content */
interface SwitchLanguageContentMessage extends OtterMessageContent<'switchLanguage'> {
/** Language */
language: string;
}
/** Display localization key message content */
interface DisplayLocalizationKeysContentMessage extends OtterMessageContent<'displayLocalizationKeys'> {
/** Toggle the display of the localization keys */
toggle?: boolean;
}
/** Update localization message content */
interface UpdateLocalizationContentMessage extends OtterMessageContent<'updateLocalization'> {
/** Localization key */
key: string;
/** Localization value */
value: string;
/** Lang */
lang?: string;
}
/** Reload localization Keys message content */
interface ReloadLocalizationKeysContentMessage extends OtterMessageContent<'reloadLocalizationKeys'> {
/** Lang */
lang?: string;
}
interface IsTranslationDeactivationEnabledContentMessage extends OtterMessageContent<'isTranslationDeactivationEnabled'> {
enabled: boolean;
}
interface GetTranslationValuesContentMessage extends OtterMessageContent<'getTranslationValuesContentMessage'> {
translations: {
[localizationKey: string]: string;
};
}
type LocalizationMessageContents = LanguagesContentMessage | ReloadLocalizationKeysContentMessage | SwitchLanguageContentMessage | LocalizationsContentMessage | DisplayLocalizationKeysContentMessage | UpdateLocalizationContentMessage | IsTranslationDeactivationEnabledContentMessage | GetTranslationValuesContentMessage;
/** List of possible DataTypes for Localization messages */
type LocalizationMessageDataTypes = MessageDataTypes<LocalizationMessageContents>;
/** List of all messages for Localization purpose */
type AvailableLocalizationMessageContents = LocalizationMessageContents | ConnectContentMessage | RequestMessagesContentMessage<LocalizationMessageDataTypes>;
/**
* Contextualization devtools exposed for localization in CMS integration
*/
interface LocalizationContextualizationDevtools {
/**
* Is the translation deactivation enabled
*/
isTranslationDeactivationEnabled(): boolean | Promise<boolean>;
/**
* Show localization keys
* @param value value enforced by the DevTools extension
*/
showLocalizationKeys: (value?: boolean) => void | Promise<void>;
/**
* Returns the current language
*/
getCurrentLanguage: () => string | Promise<string>;
/**
* Switch the current language to the specified value
* @param language new language to switch to
*/
switchLanguage: (language: string) => Promise<{
previous: string;
requested: string;
current: string;
}>;
/**
* Setup a listener on language change
* @param fn called when the language is changed in the app
*/
onLanguageChange: (fn: (language: string) => any) => Subscription;
/**
* Updates the specified localization key/values for the current language
* @param keyValues key/values to update
* @param language if not provided, the current language value
*/
updateLocalizationKeys: (keyValues: {
[key: string]: string;
}, language?: string) => void | Promise<void>;
/**
* Reload a language from the language file
* @see https://github.com/ngx-translate/core/blob/master/packages/core/lib/translate.service.ts#L490
* @param language language to reload
*/
reloadLocalizationKeys: (language?: string) => Promise<void>;
}
declare class LocalizationDevtoolsConsoleService implements DevtoolsServiceInterface, LocalizationContextualizationDevtools {
/** Name of the Window property to access to the devtools */
static readonly windowModuleName = "localization";
private readonly localizationDevtools;
private readonly options;
constructor();
/** @inheritDoc */
activate(): void;
/**
* @inheritdoc
*/
isTranslationDeactivationEnabled(): boolean | Promise<boolean>;
/**
* @inheritdoc
*/
showLocalizationKeys(value?: boolean): void | Promise<void>;
/**
* @inheritdoc
*/
getCurrentLanguage(): string | Promise<string>;
/**
* @inheritdoc
*/
switchLanguage(language: string): Promise<{
previous: string;
requested: string;
current: string;
}>;
/**
* @inheritdoc
*/
onLanguageChange(fn: (language: string) => any): Subscription;
/**
* @inheritdoc
*/
updateLocalizationKeys(keyValues: {
[key: string]: string;
}, language?: string): void | Promise<void>;
/**
* @inheritdoc
*/
reloadLocalizationKeys(language?: string): Promise<void>;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationDevtoolsConsoleService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<LocalizationDevtoolsConsoleService>;
}
declare class LocalizationDevtoolsMessageService {
private readonly logger;
private readonly localizationDevTools;
private readonly localizationService;
private readonly options;
private readonly sendMessage;
private readonly destroyRef;
constructor();
private sendLocalizationsMetadata;
/**
* Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
* @param only restricted list of messages to re-send
*/
private handleReEmitRequest;
/**
* Function to handle the incoming messages from Otter Chrome DevTools extension
* @param message Message coming from the Otter Chrome DevTools extension
*/
private handleEvents;
/**
* Function to connect the plugin to the Otter Chrome DevTools extension
*/
private connectPlugin;
/** @inheritDoc */
activate(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationDevtoolsMessageService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<LocalizationDevtoolsMessageService>;
}
/**
* Service which is wrapping the configuration logic of TranslateService from ngx-translate
* Any application willing to use localization just needs to inject LocalizationService
* in the root component and call its configure() method.
*/
declare class LocalizationService {
private readonly translateService;
private readonly logger;
private readonly configuration;
private readonly store;
private readonly localeSplitIdentifier;
/**
* Internal subject that we use to track changes between keys only and translation mode
*/
private readonly _showKeys$;
/**
* Map of localization keys to replace a key to another
*/
private readonly keyMapping$?;
/**
* _showKeys$ exposed as an Observable
*/
showKeys$: Observable<boolean>;
constructor();
/**
* This will handle the fallback language hierarchy to find out fallback language.
* supportedLocales language has highest priority, next priority goes to fallbackLocalesMap and default would be
* fallbackLanguage.
* @param language Selected language.
* @returns selected language if supported, fallback language otherwise.
*/
private checkFallbackLocalesMap;
/**
* This function checks if fallback language can be provided from fallbackLocalesMap.
* supportedLocales: ['en-GB', 'en-US', 'fr-FR'], fallbackLocalesMap: {'en-CA': 'en-US', 'de': 'fr-FR'}
* translate to en-CA -> fallback to en-US, translate to de-DE -> fallback to fr-FR
* translate to en-NZ -> fallback to en-GB
* @param language Selected language.
* @returns Fallback language if available, undefined otherwise.
*/
private getFallbackMapLangCode;
/**
* This function checks if closest supported language available incase of selected language is not
* supported language.
* supportedLocales: ['en-GB', 'en-US', 'fr-FR']
* translate to en-CA -> fallback to en-GB
* @param language Selected language.
* @returns Closest supported language if available, undefined otherwise.
*/
private getFirstClosestSupportedLanguageCode;
/**
* Returns a stream of translated values of a key which updates whenever the language changes.
* @param translationKey Key to translate
* @param interpolateParams Object to use in translation binding
* @returns A stream of the translated key
*/
private getTranslationStream;
/**
* Configures TranslateService and registers locales. This method is called from the application level.
*/
configure(): Promise<void>;
/**
* Is the translation deactivation enabled
*/
isTranslationDeactivationEnabled(): boolean;
/**
* Wrapper to call the ngx-translate service TranslateService method getLangs().
*/
getLanguages(): string[];
/**
* Wrapper to call the ngx-translate service TranslateService method use(language).
* @param language
*/
useLanguage(language: string): Observable<any>;
/**
* Wrapper to get the ngx-translate service TranslateService currentLang.
*/
getCurrentLanguage(): string;
/**
* Get the instance of the ngx-translate TranslateService used by LocalizationService.
*/
getTranslateService(): TranslateService;
/**
* Toggle the ShowKeys mode between active and inactive.
* @param value if specified, set the ShowKeys mode to value. If not specified, toggle the ShowKeys mode.
*/
toggleShowKeys(value?: boolean): void;
/**
* Return the current value of debug show/hide translation keys.
*/
get showKeys(): boolean;
/**
* Get an observable of translation key after global mapping
* @param requestedKey Original translation key
*/
getKey(requestedKey: string): Observable<any>;
/**
* Returns a stream of translated values of a key which updates whenever the language changes.
* @param key Key to translate
* @param interpolateParams Object to use in translation binding
* @returns A stream of the translated key
*/
translate(key: string, interpolateParams?: object): Observable<any>;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<LocalizationService>;
}
/**
* TranslatePipe class adding debug functionality
*/
declare class O3rLocalizationTranslatePipe extends TranslatePipe implements PipeTransform, OnDestroy {
/** Localization service instance */
protected readonly localizationService: LocalizationService;
/** Change detector service instance */
protected readonly changeDetector: ChangeDetectorRef;
/** Localization config token */
protected readonly localizationConfig: LocalizationConfiguration;
/**
* Internal subscription to the LocalizationService showKeys mode changes
*/
protected readonly onShowKeysChange?: Subscription;
/**
* Internal subscription to the LocalizationService key mapping
*/
protected onKeyChange?: Subscription;
/**
* Should we display keys instead of translations
*/
protected showKeys: boolean;
/** last key queried */
protected lastQueryKey?: string;
/** last key resolved */
protected lastResolvedKey?: string;
constructor();
/**
* Calls original transform method and eventually outputs the key if debugMode (in LocalizationConfiguration) is enabled
* @inheritdoc
*/
transform(query: string, ...args: any[]): any;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<O3rLocalizationTranslatePipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<O3rLocalizationTranslatePipe, "o3rTranslate", false>;
}
/**
* TranslateDirective class adding debug functionality
*/
declare class LocalizationTranslateDirective extends TranslateDirective implements OnDestroy {
private readonly localizationService;
private readonly localizationConfig;
/**
* Internal subscription to the LocalizationService showKeys mode changes
*/
private readonly onShowKeysChange?;
/**
* Should we display keys instead of translations
*/
private showKeys;
/**
* Internal subscription to the LocalizationService key mapping
*/
private onKeyChange?;
/** @inheritdoc */
set translate(key: string);
constructor();
/**
* Overriding parent's setContent to plug debugging feature
* @param node
* @param content
*/
setContent(node: any, content: string): void;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationTranslateDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<LocalizationTranslateDirective, "[translate],[ngx-translate]", never, { "translate": { "alias": "translate"; "required": false; }; }, {}, never, never, false, never>;
}
/**
* Native angular DatePipe taking the current lang into consideration
*/
declare class LocalizedDatePipe extends DatePipe implements OnDestroy, PipeTransform {
private readonly onLangChange;
private readonly localizationService;
private readonly changeDetectorRef;
constructor();
/**
* @inheritdoc
*/
transform(value: Date | string | number, format?: string, timezone?: string, locale?: string): string | null;
transform(value: null | undefined, format?: string, timezone?: string, locale?: string): null;
transform(value: Date | string | number | null | undefined, format?: string, timezone?: string, locale?: string): string | null;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizedDatePipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<LocalizedDatePipe, "date", false>;
}
/**
* Native angular DecimalPipe taking the current lang into consideration
*/
declare class LocalizedDecimalPipe extends DecimalPipe implements OnDestroy, PipeTransform {
private readonly onLangChange;
private readonly localizationService;
private readonly changeDetectorRef;
constructor();
/**
* @inheritdoc
*/
transform(value: number | string, digitsInfo?: string, locale?: string): string | null;
transform(value: null | undefined, digitsInfo?: string, locale?: string): null;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizedDecimalPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<LocalizedDecimalPipe, "decimal", false>;
}
/**
* Native angular CurrencyPipe taking the current lang into consideration
*/
declare class LocalizedCurrencyPipe extends CurrencyPipe implements OnDestroy, PipeTransform {
private readonly onLangChange;
private readonly localizationService;
private readonly changeDetectorRef;
constructor();
/**
* @inheritdoc
*/
transform(value: number | string, currencyCode?: string, display?: string | boolean, digitsInfo?: string, locale?: string): string | null;
transform(value: null | undefined, currencyCode?: string, display?: string | boolean, digitsInfo?: string, locale?: string): null;
transform(value: number | string | null | undefined, currencyCode?: string, display?: string | boolean, digitsInfo?: string, locale?: string): string | null;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizedCurrencyPipe, never>;
static ɵpipe: i0.ɵɵPipeDeclaration<LocalizedCurrencyPipe, "currency", false>;
}
/**
* creates LocalizationConfiguration, which is used if the application
* @param configuration Localization configuration
*/
declare function createLocalizationConfiguration(configuration?: Partial<LocalizationConfiguration>): LocalizationConfiguration;
/**
* Factory to inject the LOCALE_ID token with the current language into Angular context
* @param localizationService Localization service
*/
declare function localeIdNgBridge(localizationService: LocalizationService): string;
/** Custom Localization Configuration Token to override default localization configuration */
declare const CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN: InjectionToken<Partial<LocalizationConfiguration>>;
declare class LocalizationModule {
/**
* forRoot method should be called only once from the application index.ts
* It will do several things:
* - provide the configuration for the whole application
* - register all locales specified in the LocalizationConfiguration
* - configure TranslateService
* - inject LOCALE_ID token
* @param configuration LocalizationConfiguration
*/
static forRoot(configuration?: () => Partial<LocalizationConfiguration>): ModuleWithProviders<LocalizationModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<LocalizationModule, [typeof O3rLocalizationTranslatePipe, typeof LocalizationTranslateDirective, typeof LocalizedDatePipe, typeof LocalizedDecimalPipe, typeof LocalizedCurrencyPipe], [typeof i6.TranslateModule, typeof i7.BidiModule, typeof i8.DynamicContentModule, typeof i9.CommonModule], [typeof i6.TranslateModule, typeof O3rLocalizationTranslatePipe, typeof LocalizationTranslateDirective, typeof LocalizedDatePipe, typeof LocalizedDecimalPipe, typeof LocalizedCurrencyPipe]>;
static ɵinj: i0.ɵɵInjectorDeclaration<LocalizationModule>;
}
declare class LocalizationDevtoolsModule {
/**
* Initialize Otter Devtools
* @param options
*/
static instrument(options: Partial<LocalizationDevtoolsServiceOptions>): ModuleWithProviders<LocalizationDevtoolsModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationDevtoolsModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<LocalizationDevtoolsModule, never, [typeof LocalizationModule], never>;
static ɵinj: i0.ɵɵInjectorDeclaration<LocalizationDevtoolsModule>;
}
declare class OtterLocalizationDevtools {
private readonly localizationService;
private readonly translateCompiler;
private readonly appRef;
/**
* Is the translation deactivation enabled
*/
isTranslationDeactivationEnabled(): boolean;
/**
* Show localization keys
* @param value value enforced by the DevTools extension
*/
showLocalizationKeys(value?: boolean): void;
/**
* Returns the current language
*/
getCurrentLanguage(): string;
/**
* Setup a listener on language change
* @param fn called when the language is changed in the app
*/
onLanguageChange(fn: (language: string) => any): Subscription;
/**
* Switch the current language to the specified value
* @param language new language to switch to
*/
switchLanguage(language: string | undefined): Promise<void>;
/**
* Updates the specified localization key/values for the current language.
*
* Recommendation: To be used with a small number of keys to update to avoid performance issues.
* @param keyValues key/values to update
* @param language if not provided, the current language value
*/
updateLocalizationKeys(keyValues: {
[key: string]: string;
}, language?: string): void | Promise<void>;
/**
* Reload a language from the language file
* @see https://github.com/ngx-translate/core/blob/master/packages/core/lib/translate.service.ts#L490
* @param language language to reload
*/
reloadLocalizationKeys(language?: string): Promise<void>;
static ɵfac: i0.ɵɵFactoryDeclaration<OtterLocalizationDevtools, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<OtterLocalizationDevtools>;
}
declare const OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS: Readonly<LocalizationDevtoolsServiceOptions>;
declare const OTTER_LOCALIZATION_DEVTOOLS_OPTIONS: InjectionToken<LocalizationDevtoolsServiceOptions>;
/**
* LocalizationOverride store state
*/
interface LocalizationOverrideState {
/** Mapping of initial localization keys to the one they are replaced with */
localizationOverrides: Record<string, string>;
}
/**
* Name of the LocalizationOverride Store
*/
declare const LOCALIZATION_OVERRIDE_STORE_NAME = "localizationOverride";
/**
* LocalizationOverride Store Interface
*/
interface LocalizationOverrideStore {
/** LocalizationOverride state */
[LOCALIZATION_OVERRIDE_STORE_NAME]: LocalizationOverrideState;
}
/**
* Clear all overrides and fill the store with the payload
*/
declare const setLocalizationOverride: _ngrx_store.ActionCreator<"[LocalizationOverride] set", (props: SetStateActionPayload<LocalizationOverrideState>) => SetStateActionPayload<LocalizationOverrideState> & _ngrx_store.Action<"[LocalizationOverride] set">>;
/** Token of the LocalizationOverride reducer */
declare const LOCALIZATION_OVERRIDE_REDUCER_TOKEN: InjectionToken<ActionReducer<LocalizationOverrideState, Action<string>>>;
/** Provide default reducer for LocalizationOverride store */
declare function getDefaultLocalizationOverrideReducer(): ActionReducer<LocalizationOverrideState, Action<string>>;
declare class LocalizationOverrideStoreModule {
static forRoot<T extends LocalizationOverrideState>(reducerFactory: () => ActionReducer<T, Action>): ModuleWithProviders<LocalizationOverrideStoreModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationOverrideStoreModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<LocalizationOverrideStoreModule, never, [typeof _ngrx_store.StoreFeatureModule], never>;
static ɵinj: i0.ɵɵInjectorDeclaration<LocalizationOverrideStoreModule>;
}
/**
* LocalizationOverride Store initial value
*/
declare const localizationOverrideInitialState: LocalizationOverrideState;
/**
* List of basic actions for LocalizationOverride Store
*/
declare const localizationOverrideReducerFeatures: ReducerTypes<LocalizationOverrideState, ActionCreator[]>[];
/**
* LocalizationOverride Store reducer
*/
declare const localizationOverrideReducer: _ngrx_store.ActionReducer<LocalizationOverrideState, _ngrx_store.Action<string>>;
/** Select LocalizationOverride State */
declare const selectLocalizationOverrideState: _ngrx_store.MemoizedSelector<object, LocalizationOverrideState, _ngrx_store.DefaultProjectorFn<LocalizationOverrideState>>;
/** Select all localization override map */
declare const selectLocalizationOverride: _ngrx_store.MemoizedSelector<object, Record<string, string>, (s1: LocalizationOverrideState) => Record<string, string>>;
declare const localizationOverrideStorageDeserializer: (rawObject: any) => any;
declare const localizationOverrideStorageSync: Serializer<LocalizationOverrideState>;
/**
* 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)
*/
declare class TranslationsLoader implements TranslateLoader {
private readonly localizationConfiguration;
private readonly logger?;
private readonly dynamicContentService?;
/**
* 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, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationsLoader>;
}
/**
* Creates a loader of translations bundles based on the configuration
* (endPointUrl and language determine which bundle we load and where do we fetch it from)
* @param localizationConfiguration
* @param logger service to handle the log of warning and errors
* @param dynamicContentService (optional)
*/
declare function createTranslateLoader(localizationConfiguration: LocalizationConfiguration, logger?: LoggerService, dynamicContentService?: DynamicContentService): TranslationsLoader;
/**
* TranslateLoader provider, using framework's TranslationsLoader class
*/
declare const translateLoaderProvider: Readonly<FactoryProvider>;
/** Localization Configuration Token */
declare const LOCALIZATION_CONFIGURATION_TOKEN: InjectionToken<LocalizationConfiguration>;
/**
* Service for handling the text direction based on the LocalizationConfiguration
*/
declare class TextDirectionService {
private readonly translateService;
private readonly configuration;
private readonly rendererFactory;
private readonly directionality;
private subscription?;
private readonly renderer;
constructor();
/**
* Updates the dir attribute on body HTML tag.
* @returns a subscription that updates the dir attribute
*/
onLangChangeSubscription(): Subscription;
static ɵfac: i0.ɵɵFactoryDeclaration<TextDirectionService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TextDirectionService>;
}
/**
* @deprecated The value of Directionality is no longer readonly and can be updated, this class will be removed in v16
*/
declare class TextDirectionality extends Directionality implements OnDestroy {
get value(): Direction;
set value(value: Direction);
/**
* The current 'ltr' or 'rtl' value.
* @override
*/
private _value;
constructor();
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<TextDirectionality, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TextDirectionality>;
}
export { CUSTOM_LOCALIZATION_CONFIGURATION_TOKEN, DEFAULT_LOCALIZATION_CONFIGURATION, LOCALIZATION_CONFIGURATION_TOKEN, LOCALIZATION_OVERRIDE_REDUCER_TOKEN, LOCALIZATION_OVERRIDE_STORE_NAME, Localization, LocalizationDevtoolsConsoleService, LocalizationDevtoolsMessageService, LocalizationDevtoolsModule, LocalizationModule, LocalizationOverrideStoreModule, LocalizationService, LocalizationTranslateDirective, LocalizedCurrencyPipe, LocalizedDatePipe, LocalizedDecimalPipe, MESSAGE_FORMAT_CONFIG, O3rLocalizationTranslatePipe, OTTER_LOCALIZATION_DEVTOOLS_DEFAULT_OPTIONS, OTTER_LOCALIZATION_DEVTOOLS_OPTIONS, OtterLocalizationDevtools, TextDirectionService, TextDirectionality, TranslateMessageFormatLazyCompiler, TranslationsLoader, createLocalizationConfiguration, createTranslateLoader, getDefaultLocalizationOverrideReducer, lazyMessageDefaultConfig, localeIdNgBridge, localizationOverrideInitialState, localizationOverrideReducer, localizationOverrideReducerFeatures, localizationOverrideStorageDeserializer, localizationOverrideStorageSync, selectLocalizationOverride, selectLocalizationOverrideState, setLocalizationOverride, translateLoaderProvider };
export type { AvailableLocalizationMessageContents, DisplayLocalizationKeysContentMessage, GetTranslationValuesContentMessage, IsTranslationDeactivationEnabledContentMessage, JSONLocalization, LanguagesContentMessage, LazyMessageFormatConfig, LocalizationConfiguration, LocalizationContextualizationDevtools, LocalizationDevtoolsServiceOptions, LocalizationMessageDataTypes, LocalizationMetadata, LocalizationOverrideState, LocalizationOverrideStore, LocalizationsContentMessage, ReloadLocalizationKeysContentMessage, SwitchLanguageContentMessage, Translatable, UpdateLocalizationContentMessage };
//# sourceMappingURL=index.d.ts.map