import * as i0 from '@angular/core'; import { PipeTransform } from '@angular/core'; import { Observable } from 'rxjs'; type TranslationObject = Record>; declare class TranslatePipe implements PipeTransform { private readonly translateService; transform(key: string, placeholder?: Record): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } /** * Service for translating keys into localized text. It listens to changes in the active language * and provides translated strings based on the current language preference. The service uses * provided `TranslationObject` containing the translations for each supported language. * * @example * ```ts * // Using TranslateService in a component * class MyComponent { * constructor(private translateService: TranslateService) { * translateService.translate('greeting').subscribe(translatedText => { * console.log(translatedText); // Outputs "Hello" or "Bonjour" based on the active language * }); * } * } * ``` */ declare class TranslateService { private readonly translations; private readonly localizationService; /** * An observable that emits the current translation object based on the active language. * It ensures that translations are updated dynamically whenever the user's language preference changes. * * @emits {TranslationObject} activeTranslation$ - The translation object for the active language. */ readonly activeTranslation$: Observable>; constructor(translations: TranslationObject); /** * Translates a key into its localized text, optionally replacing placeholders with dynamic values. * @param {string} key - The translation key to translate. * @param {Record} [data={}] - An object mapping placeholder names to replacement values. * @returns {Observable} An observable emitting the translated text, with placeholders replaced by provided values. */ translate(key: string, data?: Record): Observable; } /** * Provides a configuration for Angular's dependency injection system to instantiate the `TranslateService` * with a specific set of translations. This function is useful for setting up the translation service * at the module level, ensuring that a single instance with a consistent set of translations is used * throughout the application. * * @param {TranslationObject} translations - An object containing key-value pairs where each key is a * translation key and the value is the translated string or an object containing translations for * nested keys. This object should include translations for all supported languages. * @returns {Provider} An Angular provider configuration object that can be used in the `providers` array * of an `@NgModule` or `@Component` decorator to supply the `TranslateService` with the provided translations. * * @example * ```ts * // Example usage in an Angular module * import { NgModule } from '@angular/core'; * import { provideTranslations } from '@odx/angular/internal/translate'; * * const appTranslations = { * en: { welcome: "Welcome" }, * fr: { welcome: "Bienvenue" } * }; * * @NgModule({ * providers: [ * provideTranslations(appTranslations) * ] * }) * export class AppModule { } * ``` */ declare function provideTranslations(translations: TranslationObject): { provide: typeof TranslateService; useFactory: () => TranslateService; }; export { TranslatePipe, TranslateService, provideTranslations }; export type { TranslationObject };