UNPKG

@ogs-gmbh/ngx-translate

Version:

A lightweight, REST-based Angular i18n library designed for seamless internationalization with minimal setup. It supports dynamic language switching & flexible translation management via RESTful APIs.

1,189 lines (1,164 loc) 35.7 kB
import { HttpOptions, HttpHeadersOption, HttpConfig, HttpRequestStatus } from '@ogs-gmbh/ngx-http'; import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpClient } from '@angular/common/http'; import { Observable, Subject } from 'rxjs'; import * as i0 from '@angular/core'; import { PipeTransform, InjectionToken, ValueProvider, FactoryProvider, EnvironmentProviders, ClassProvider, ModuleWithProviders } from '@angular/core'; import * as i1 from '@angular/common'; /** * Strategies for collecting translations in the application, so that they don't have to be fetched multiple times. * @remarks Each option describes which {@link LocaleConfig} should be collected. * @deprecated Use {@link CollectingStrategy} instead. It'll be removed in upcoming releases. * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare enum CollectingStrategies { /** * Collect every translation, regardless of the current {@link LocaleConfig} * * @since 1.0.0 * @author Simon Kovtyk */ ALL = "all", /** * Collect only translations of the current locale * * @since 1.0.0 * @author Simon Kovtyk */ CURRENT = "current" } /** * Strategies for collecting translations in the application, so that they don't have to be fetched multiple times. * @remarks Each option describes which {@link LocaleConfig} should be collected. * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare enum CollectingStrategy { /** * Collect every translation, regardless of the current locale * * @since 1.0.0 * @author Simon Kovtyk */ ALL = "all", /** * Collect only translations of the current locale * * @since 1.0.0 * @author Simon Kovtyk */ CURRENT = "current" } /** * Strategies for preloading translations * @remarks Each option describes when the preload should happen. * @category NG config * @deprecated Use {@link PreloadingStrategy} instead. It'll be removed in upcoming releases. * * @since 1.0.0 * @author Simon Kovtyk */ declare enum PreloadingStrategies { /** * Preload translations during application initialization * * @since 1.0.0 * @author Simon Kovtyk */ INITIALIZATION = "initialization", /** * Preload translations during application runtime * * @since 1.0.0 * @author Simon Kovtyk */ RUNTIME = "runtime" } /** * Strategies for preloading translations * @remarks Each option describes when the preload should happen. * @category NG config * * @since 2.0.0 * @author Simon Kovtyk */ declare enum PreloadingStrategy { /** * Preload translations during application initialization * * @since 2.0.0 * @author Simon Kovtyk */ INITIALIZATION = "initialization", /** * Preload translations during application runtime * * @since 2.0.0 * @author Simon Kovtyk */ RUNTIME = "runtime" } /** * Snapshot of the {@link ScopeNotDefinedError} properties for serialization purposes * @category Types * * @since 2.0.0 * @author Simon Kovtyk */ type ScopeNotDefinedStateSnapshot = { /** * Indicates whether the default scope is not defined * * @since 2.0.0 * @author Simon Kovtyk */ isDefaultScope: boolean; /** * Name of the scope that is not defined * * @since 2.0.0 * @author Simon Kovtyk */ scope?: string; /** * {@link LocaleConfig} of the scope that is not defined in the translations * * @since 2.0.0 * @author Simon Kovtyk */ locale?: LocaleConfig; }; /** * Error thrown when a scope is not defined * @category Errors * * @since 1.0.0 * @author Simon Kovtyk */ declare class ScopeNotDefinedError extends Error { readonly name: string; constructor(snapshot: ScopeNotDefinedStateSnapshot); } /** * Snapshot of the {@link LocaleNotDefinedError} properties for serialization purposes. * @category Types * * @since 2.0.0 * @author Simon Kovtyk */ type LocaleNotDefinedStateSnapshot = { /** * {@link LocaleConfig}, that is not defined * * @since 2.0.0 * @author Simon Kovtyk */ locale: LocaleConfig; }; /** * Error thrown when a requested {@link LocaleConfig} is not defined * @category Errors * * @since 1.0.0 * @author Simon Kovtyk */ declare class LocaleNotDefinedError extends Error { readonly name: string; constructor(locale: LocaleConfig); } /** * Snapshot of the translation that is not defined * @category Types * * @since 2.0.0 * @author Simon Kovtyk */ type TranslationNotDefinedStateSnapshot = { /** * Token for which the translation is not defined in the translations * * @since 2.0.0 * @author Simon Kovtyk */ token: string; /** * Value of the translation that is not defined in the translations * * @since 2.0.0 * @author Simon Kovtyk */ value?: string; /** * Scope of the translation that is not defined in the translations * * @since 2.0.0 * @author Simon Kovtyk */ scope?: ReadonlyArray<string | null> | string | null; /** * {@link LocaleConfig} of the translation that is not defined in the translations * * @since 2.0.0 * @author Simon Kovtyk */ locale?: LocaleConfig; }; /** * Error thrown when a translation for a given token is not defined * @category Errors * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationNotDefinedError extends Error { name: string; constructor(snapshot: TranslationNotDefinedStateSnapshot); } /** * Snapshot of the {@link SourceLocaleNotDefinedError} properties for serialization purposes * @category Types * * @since 2.0.0 * @author Simon Kovtyk */ type SourceLocaleNotDefinedStateSnapshot = { /** * {@link LocaleConfig} of the source locale that is not defined in the translation configuration * * @since 2.0.0 * @author Simon Kovtyk */ locale?: LocaleConfig; }; /** * Error thrown when a {@link LocaleConfig} as source locale is not defined * @category Errors * * @since 1.0.0 * @author Simon Kovtyk */ declare class SourceLocaleNotDefinedError extends Error { readonly name: string; constructor(snapshot?: SourceLocaleNotDefinedStateSnapshot); } /** * Interceptor to add the current locale language header to HTTP requests. * @remarks Adds a `language` header with `value` of the current {@link LocaleConfig} to each outgoing HTTP request. * @category NG interceptors * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationInterceptor implements HttpInterceptor { private readonly _translationStoreService; intercept(httpRequest: Readonly<HttpRequest<unknown>>, httpHandler: Readonly<HttpHandler>): Observable<HttpEvent<unknown>>; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationInterceptor, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslationInterceptor>; } /** * Core pipe to translate content inside an Angular Template * @category NG pipes * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationPipe implements PipeTransform { private readonly _translationSnapshot$; private readonly _destroyRef; private _lastValue; private readonly _translationService; private readonly _changeDetectorRef; private readonly _translationScopeToken; private readonly _translationConfig; constructor(); /** * Transforms a token into its translated value * * @param value - The possible fallback value, if no translation was found. Check the `fallback` parameter * @param token - The token to be translated * @param scope - Optional scope(s) to narrow down the translation search * @param shouldFallback - Optional flag to determine if it should fallback to the source locale when no translation was found. If not provided, {@link TranslationNotDefinedError} will be thrown instead. * @returns The translated token or the fallback value * * @since 1.0.0 * @author Simon Kovtyk */ transform(value: string, token: string, scope?: Readonly<Array<string | null> | string | null>, shouldFallback?: boolean): string; private _resolveScope; private _updateLastValue; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<TranslationPipe, "translate", true>; } /** * Core service as abstraction layer for HTTP handling * @category NG services * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationHttpService { private readonly _translationHttpConfig; private readonly _translationConfig; private readonly _translationHttpOptions; /** * Gets translations with the provided `HttpClient` reference. * * @param httpClientRef - The `HttpClient` reference to use for the request. * @param scopeName - The scope name(s) for the translations. * @param httpOptions - Optional `HttpOptions` to customize the request. * @returns An `Observable` of the requested translations. * * @since 1.0.0 * @author Simon Kovtyk */ getWithRef$<T>(httpClientRef: Readonly<HttpClient>, scopeName: ReadonlyArray<string | null> | string | null, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<T>; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationHttpService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslationHttpService>; } /** * Scoped file, that represents a translation set for a specific scope * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type ScopedFile = Readonly<Record<string, string>>; /** * Multi Scoped file, that represents multiple translation sets for a specific scopes * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type MultiScopedFile = Readonly<Record<string, ScopedFile>>; /** * Parsed multi scoped file * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type ParsedMultiScopedFile = { /** * Scope name * * @since 1.0.0 * @author Simon Kovtyk */ readonly scopeName: string | null; /** * Scoped file content * * @since 1.0.0 * @author Simon Kovtyk */ readonly file: ScopedFile; }; /** * Parsed multi scoped files * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type ParsedMultiScopedFiles = ParsedMultiScopedFile[]; /** * Loaded scope * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type LoadedScope = { readonly scope: string | null; file: ScopedFile; }; /** * Loaded scope array * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type LoadedScopes = LoadedScope[]; /** * Locale loaded scopes * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type LocaleLoadedScopes = Record<string, LoadedScopes>; /** * Notifier scopes (storage) * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type NotifierScope = { /** * Scope name * * @since 1.0.0 * @author Simon Kovtyk */ readonly scope: string | null; /** * Subject notifiers for the scope * * @since 1.0.0 * @author Simon Kovtyk */ notifiers: Array<Subject<ScopedFile>> | null; }; /** * Notifier scopes array * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type NotifierScopes = NotifierScope[]; /** * Multi scope based notifier scope * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type MultiScopeBasedNotifierScope = ReadonlyArray<Subject<ScopedFile>> | null; /** * Mutli scope based notifier scopes * @category Types * * @since 1.0.0 * @author Simon Kovtyk */ type MultiScopeBasedNotifierScopes = Record<string, MultiScopeBasedNotifierScope> & { /** * Notifiers, that provide a set of scoped files * * @since 1.0.0 * @author Simon Kovtyk */ notifiers?: ReadonlyArray<Subject<ScopedFile>> | null | undefined; }; /** * Description of a locale, your app should support * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ type LocaleConfig = { /** * The locale value, e.g. "en", "de" or "fr" * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly value: string; /** * The locale name, e.g. "English", "Deutsch" or "Français" * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly name?: string; /** * Marks the locale as source locale. A source locale is the locacle, used in your source code. * @remarks Only one locale should be marked as source locale * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly isSource?: boolean; }; /** * Specific translation configuration * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ type SpecificTranslateConfig = { /** * The locales in Form of {@link LocaleConfig}, your app should support * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly locales: LocaleConfig[]; /** * The timeout for HTTP requests in millisecond * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly timeout?: number | undefined; /** * Overrides the global scope, which should be used as default scope when no scope is provided. Default is `null`. * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly defaultScope?: string | undefined; /** * Fallback to source locale translations, when a translation is missing in the current locale. Default is `false`. * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly fallbackToSourceLocale?: boolean | undefined; /** * Configuration for storing locale and translations in the browser storage * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly storageConfig?: { /** * The {@link CollectingStrategy} to use for collecting translations to store in the browser storage * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly collectingStrategy?: CollectingStrategy | undefined; /** * Configuration for storing the current locale in the browser storage * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly locale?: { /** * The key to use for storing the current locale * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly key?: string | undefined; /** * The storage type to use for storing the current locale (e.g. `localeStorage` or `sessionStorage`) * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly type?: Storage | undefined; /** * Wether to store the current locale in the browser storage or not. Default is `false`. * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly store?: boolean | undefined; } | undefined; /** * Configuration for storing the translations in the browser storage * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly translations?: { /** * The key to use for storing the translations * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly key?: string | undefined; /** * The storage type to use for storing the translations (e.g. `localeStorage` or `sessionStorage`) * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly type?: Storage | undefined; /** * Wether to store the translations in the browser storage or not. Default is `false`. * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly store?: boolean | undefined; } | undefined; } | undefined; }; /** * Configuration * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ type TranslateConfig = { /** * Configuration for HTTP requests * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly http: { /** * The HTTP configuration * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ config: HttpConfig; /** * Additional HTTP options (e.g. headers), which will be merged with other HTTP options * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ options?: HttpOptions<never, HttpHeadersOption, never>; }; /** * Translation-related configuration * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly translate: SpecificTranslateConfig; }; /** * Core service as abstraction layer for translaton storage and state management * @category NG services * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationStoreService { private _loadedScopes; private _notifierScopes; private readonly _translationConfig; private readonly _locale; private readonly _locale$; private readonly _storageAttributes; constructor(); /** * Get the current {@link LocaleConfig} * * @returns The current {@link LocaleConfig} * * @since 1.0.0 * @author Simon Kovtyk */ getCurrentLocale(): LocaleConfig; /** * Get an `Observable` of the current {@link LocaleConfig} * * @returns An `Observable` of the current {@link LocaleConfig} * * @since 1.0.0 * @author Simon Kovtyk */ getLocale$(): Observable<LocaleConfig>; /** * Set the current {@link LocaleConfig} * * @param locale - The locale to set * @throws {@link LocaleNotDefinedError} if the provided locale is not defined * * @since 1.0.0 * @author Simon Kovtyk */ setLocale(locale: LocaleConfig): void; /** * Get all defined locales * * @returns An `Array` of all defined locales * * @since 1.0.0 * @author Simon Kovtyk */ getLocales(): LocaleConfig[]; /** * Set a scoped file * * @param scopeName - The name of the scope * @param file - The scoped file to set * * @since 1.0.0 * @author Simon Kovtyk */ setScopedFile(scopeName: string | null, file: ScopedFile): void; /** * Get a scoped file * * @param scopeName - The name of the scope, the {@link ScopedFile} belongs to * @returns if found {@link ScopedFile}, otherwise `undefined` * * @since 1.0.0 * @author Simon Kovtyk */ getScopedFile(scopeName: string | null): ScopedFile | undefined; /** * Check if a scoped file exists * * @param scopeName - The name of the scope, the {@link ScopedFile} belongs to * @returns `true` if found, otherwise `false` * * @since 1.0.0 * @author Simon Kovtyk */ hasScopedFile(scopeName: string | null): boolean; /** * Check if scoped files exist * * @param scopeNames - An `Array` of scope names, the ScopedFiles belong to * @returns `true` if all could be found, otherwise `false` * * @since 1.0.0 * @author Simon Kovtyk */ hasScopedFiles(scopeNames: ReadonlyArray<string | null>): boolean; /** * Check if a scope exists * * @param scopeName - The name of the scope * @returns `true` if found, otherwise `false` * * @since 1.0.0 * @author Simon Kovtyk */ isScopeExisting(scopeName: string | null): boolean; /** * Check which scopes exist * * @param scopeNames - An `Array` of scope names, that should be checked * @returns An `Array` of existing scope names * * @since 1.0.0 * @author Simon Kovtyk */ getExistingScopes(scopeNames: ReadonlyArray<string | null>): Array<string | null>; /** * Check if scope name is in notifier scopes * * @param scopeName - The name of the scope * @returns `true` if found, otherwise `false` * * @since 1.0.0 * @author Simon Kovtyk */ isScopeNameInNotifierScopes(scopeName: string | null): boolean; /** * Check if scope names are in notifier scopes * * @param scopeNames - An `Array` of scope names, that should be checked * @returns `true` if all are found, otherwise `false` * * @since 1.0.0 * @author Simon Kovtyk */ areScopeNamesInNotifierScopes(scopeNames: ReadonlyArray<string | null>): boolean; /** * Check which scope names are in notifier scopes * * @param scopeNames - An `Array` of scope names, that should be checked * @returns An `Array` of existing scope names * * @since 1.0.0 * @author Simon Kovtyk */ getExistingNotifierScopes(scopeNames: ReadonlyArray<string | null>): Array<string | null>; /** * Get {@link NotifierScope} by scope name * * @param scopeName - The name of the scope * @returns if found {@link NotifierScope}, otherwise `undefined` * * @since 1.0.0 * @author Simon Kovtyk */ getNotiferScope(scopeName: string | null): NotifierScope | undefined; /** * Get {@link NotifierScopes} by scope names * * @param scopeNames - An `Array` of scope names * @returns if found {@link NotifierScopes}, otherwise `undefined` * * @since 1.0.0 * @author Simon Kovtyk */ getNotifierScopes(scopeNames: ReadonlyArray<string | null>): NotifierScopes | undefined; /** * Add a notifier scope * * @param notifierScope - The notifier scope to add * * @since 1.0.0 * @author Simon Kovtyk */ addNotifierScope(notifierScope: Readonly<NotifierScope>): void; /** * Add multiple notifier scopes * * @param notifierScopes - The notifier scopes to add * * @since 1.0.0 * @author Simon Kovtyk */ addNotifierScopes(notifierScopes: NotifierScopes): void; /** * Add a notifier to a notifier scope * * @param scopeName - The name of the scope * @param notifier - The notifier to add * * @since 1.0.0 * @author Simon Kovtyk */ addNotifierToNotifierScope(scopeName: string | null, notifier: Subject<ScopedFile>): void; /** * Remove a notifier scope * * @param scopeName - The name of the scope * * @since 1.0.0 * @author Simon Kovtyk */ removeNotifierScope(scopeName: string | null): void; /** * Get the source {@link LocaleConfig} * * @returns if defined {@link LocaleConfig}, otherwise `undefined` * * @since 1.0.0 * @author Simon Kovtyk */ getSourceLocale(): LocaleConfig | undefined; private _checkIfLocaleExists; private _checkIfLocaleIsSourceLocale; private _setStorageValue; private _getStorageValue; private _getScopeByScopeName; private _getScopeByScopeNames; private _appendScope; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationStoreService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslationStoreService>; } /** * Core service for translation handling * @category NG services * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationService { private readonly _httpClient; private readonly _translationConfig; private readonly _translationStoreService; private readonly _translationHttpService; private readonly _isHttpLoading; private readonly _isHttpLoading$; /** * An `Observable`, that will emit only when a HTTP-Request is made * @returns An `Observable` with the `HttpRequestStatus` if HTTP is currently under use. Otherwise an `Observable` with null inside. * * @since 1.0.0 * @author Simon Kovtyk */ isHttpLoading$(): Observable<HttpRequestStatus | null>; /** * Preload multiple translations with references * @param httpClient - The `HttpClient`, that'll be used * @param translationStoreService - The {@link TranslationStoreService}, that'll be used * @param translationHttpService - The {@link TranslationHttpService}, that'll be used * @param _locale - The {@link LocaleConfig}, that should be preloaded * @param scopeName - The scope name for the lookup of the translation * @param httpOptions - Additional HTTP Options for the request * @returns An `Observable` to handle the status * * @since 1.0.0 * @author Simon Kovtyk */ _preloadWithRef$(httpClient: Readonly<HttpClient>, translationStoreService: Readonly<TranslationStoreService>, translationHttpService: Readonly<TranslationHttpService>, _locale: LocaleConfig, scopeName: ReadonlyArray<string | null> | string | null, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<void>; /** * Translates a token by the locale reactive * @param token - The token to resolve the translation * @param value - The default value of the translation * @param scopeName - A scope name to resolve the lookup * @param httpOptions - Additional HTTP Options for the request * @returns An `Observable` with the current translation as `string` * * @remarks * If the {@link LocaleConfig}, a new translation based on the new locale will be emitted. * * @since 1.0.0 * @author Simon Kovtyk */ translateTokenByLocale$(token: string, value: string, scopeName?: ReadonlyArray<string | null> | string | null, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<string>; /** * Translates a token by the current locale * @param token - The token to resolve the translation * @param value - The default value of the translation * @param scopeName - A scope name to resolve the lookup * @param httpOptions - Additional HTTP Options for the request * @returns An `Observable` with the current translation as `string` * * @remarks * If the {@link LocaleConfig}, no new translation will be emitted. * * @since 1.0.0 * @author Simon Kovtyk */ translateTokenByCurrentLocale$(token: string, value: string, scopeName?: ReadonlyArray<string | null> | string | null, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<string>; /** * Preload translations by locale * @param httpClient - The `HttpClient`, that'll be used * @param translationStoreService - The {@link TranslationStoreService}, that'll be used * @param translationHttpService - The {@link TranslationHttpService}, that'll be used * @param scopeName - The scope name for the lookup of the translation * @param httpOptions - Additional HTTP Options for the request * @returns An `Observable` to handle the status * * @remarks * If the {@link LocaleConfig} changes, the scope will be preloaded again. * * @since 1.0.0 * @author Simon Kovtyk */ preloadByLocale(httpClient: Readonly<HttpClient>, translationStoreService: Readonly<TranslationStoreService>, translationHttpService: Readonly<TranslationHttpService>, scopeName: string | null | ReadonlyArray<string | null>, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<void>; /** * Preload translations by locale * @param httpClient - The `HttpClient`, that'll be used * @param translationStoreService - The {@link TranslationStoreService}, that'll be used * @param translationHttpService - The {@link TranslationHttpService}, that'll be used * @param scopeName - The scope name for the lookup of the translation * @param httpOptions - Additional HTTP Options for the request * @returns An `Observable` to handle the status * * @remarks * If the {@link LocaleConfig} changes, no new preloading will be made. * * @since 1.0.0 * @author Simon Kovtyk */ preloadByCurrentLocale(httpClient: Readonly<HttpClient>, translationStoreService: Readonly<TranslationStoreService>, translationHttpService: Readonly<TranslationHttpService>, scopeName: string | null | ReadonlyArray<string | null>, httpOptions?: HttpOptions<never, HttpHeadersOption, never>): Observable<void>; private _resolveScope; private _translateBySourceLocale; private _translateByStore; private _getScopedFileByNotifier; private _getScopedFileByAddingNotifier; private _getScopedFileByHttpWithRef$; private _translateWithRef$; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>; } /** * Injection token for {@link SpecificTranslateConfig} * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const TRANSLATION_CONFIG_TOKEN: InjectionToken<SpecificTranslateConfig>; /** * Injection token that holds a translation scope * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const TRANSLATION_SCOPE_TOKEN: InjectionToken<string>; /** * Injection token for translation preloading * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const TRANSLATION_PRELOAD_TOKEN: InjectionToken<string>; /** * Represents a localizable Translation with all required properties * @category Types * * @since 1.4.0 * @author Ian Wenneckers */ type TranslationSnapshot = { /** * Value, that gets piped * * @remarks Will be used as possible fallback value. * * @since 1.4.0 * @author Ian Wenneckers */ value: string; /** * Token, that was used to translate the value * * @since 1.4.0 * @author Ian Wenneckers */ token: string; /** * Scope, that was searched for `token` * * @since 1.4.0 * @author Ian Wenneckers */ scope?: Readonly<string | Array<string | null> | null> | undefined; /** * Flag, that enables fallbacks to `value` * * @since 1.4.0 * @author Ian Wenneckers */ shouldFallback?: boolean | undefined; }; /** * Provide a translation scope * * @param scope - The translation scope to provide * @returns A `ValueProvider` for the translation scope * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const provideTranslationScope: (scope: string) => ValueProvider; /** * Base provider type for translation preloading * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ type TranslationBaseProvider = { /** * {@link PreloadingStrategy} to use * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly preloadingStrategy: PreloadingStrategy; /** * Additional HTTP options for translation preloading requests (e.g. headers) * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly httpOptions?: HttpOptions<never, HttpHeadersOption, never> | undefined; }; /** * Provider type for translation preloading with HTTP scopes * @readonly * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ type TranslationPreloadProvider = TranslationBaseProvider & { /** * Translation scopes to preload * @readonly * * @since 1.0.0 * @author Simon Kovtyk */ readonly scopes: Array<string | null> | string | null; }; /** * Provide translation preloading based on the specified {@link PreloadingStrategy} * * @param preloadProvider - The {@link TranslationPreloadProvider} configuration * @returns A `FactoryProvider` for translation preloading * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const provideTranslationPreload: (preloadProvider: Readonly<TranslationPreloadProvider>) => FactoryProvider | EnvironmentProviders; /** * Provide reactive translation preloading based on the specified {@link PreloadingStrategy} * * @param preloadProvider - The {@link TranslationPreloadProvider} configuration * @returns A `FactoryProvider` for reactive translation preloading * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const provideTranslationPreloadReactive: (preloadProvider: Readonly<TranslationPreloadProvider>) => FactoryProvider | EnvironmentProviders; /** * Provides a translation configuration * * @param translationConfig - The {@link SpecificTranslateConfig} configuration to provide * @returns A `ValueProvider` for the translation configuration * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const provideTranslationConfig: (translationConfig: Readonly<SpecificTranslateConfig>) => ValueProvider; /** * Provide the translation HTTP interceptor * * @returns A `ClassProvider` for the `TranslationInterceptor` * @category NG config * * @since 1.0.0 * @author Simon Kovtyk */ declare const provideTranslationInterceptor: () => ClassProvider; /** * Translation Module, that bundles all translation related functionality * @category NG modules * * @since 1.0.0 * @author Simon Kovtyk */ declare class TranslationModule { /** * Configure the Translation Module with the specified configuration * @param translateConfig - The {@link TranslateConfig} * @returns A `ModuleWithProviders` for the {@link TranslationModule} with the provided configuration * * @since 1.0.0 * @author Simon Kovtyk */ static forRoot(translateConfig: Readonly<TranslateConfig>): ModuleWithProviders<TranslationModule>; static ɵfac: i0.ɵɵFactoryDeclaration<TranslationModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<TranslationModule, never, [typeof i1.CommonModule], never>; static ɵinj: i0.ɵɵInjectorDeclaration<TranslationModule>; } export { CollectingStrategies, CollectingStrategy, LocaleNotDefinedError, PreloadingStrategies, PreloadingStrategy, ScopeNotDefinedError, SourceLocaleNotDefinedError, TRANSLATION_CONFIG_TOKEN, TRANSLATION_PRELOAD_TOKEN, TRANSLATION_SCOPE_TOKEN, TranslationHttpService, TranslationInterceptor, TranslationModule, TranslationNotDefinedError, TranslationPipe, TranslationService, TranslationStoreService, provideTranslationConfig, provideTranslationInterceptor, provideTranslationPreload, provideTranslationPreloadReactive, provideTranslationScope }; export type { LoadedScope, LoadedScopes, LocaleConfig, LocaleLoadedScopes, LocaleNotDefinedStateSnapshot, MultiScopeBasedNotifierScope, MultiScopeBasedNotifierScopes, MultiScopedFile, NotifierScope, NotifierScopes, ParsedMultiScopedFile, ParsedMultiScopedFiles, ScopeNotDefinedStateSnapshot, ScopedFile, SourceLocaleNotDefinedStateSnapshot, SpecificTranslateConfig, TranslateConfig, TranslationBaseProvider, TranslationNotDefinedStateSnapshot, TranslationPreloadProvider, TranslationSnapshot };