import { TranslateService, MissingTranslationHandler, MissingTranslationHandlerParams, TranslateLoader } from '@ngx-translate/core'; import * as i0 from '@angular/core'; import { Observable } from 'rxjs'; declare class HsLanguageService { /** * ISO 639-1 code of current language */ language: string; /** * Controls whether hs-lang URL param should override other setting or not * Not in case we are syncing langs with Wagtail */ langFromCMS: boolean; private translationService; private hsConfig; private hsLog; constructor(); /** * Set up languages - default, list of allowed, the one to use */ initLanguages(): void; /** * Set language * @param lang - Language code */ setLanguage(lang: string, retryCount?: number): void; getTranslator(): TranslateService; /** * Get code of current language * @returns Language code */ getCurrentLanguageCode(): string; /** * Get array of available languages based * @returns Available languages */ listAvailableLanguages(): { key: string; name: string; }[]; /** * @param str - Identifier of the string to be translated * @param params - Dynamic params included in the translation * @returns Translation */ getTranslation(str: string, params?: any): string; /** * Async variant of getTranslation function for translations which might * be needed immediately after application init before locales are even loaded */ awaitTranslation(str: string, params?: any): Promise; /** * @param module - Module to look for inside the locales json * @param text - Text that represents the translation * @param params - Dynamic params included in the translation, for example, * "translation": "This is my \{\{nr\}\} translation" - params: \{nr: 'first'\} * @returns Translation */ getTranslationIgnoreNonExisting(module: string, text: string, params?: any): string; /** * Parse language code from HTML lang attr * Takes only first part of lang definition in case 'en-us' format is used */ private getDocumentLang; /** * If possible sync language with HTML document lang attribute * otherwise use lang used in config or default (en) */ private getLangToUse; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * This service handles cases where translation keys are missing from the translation files. * It provides fallback behavior by: * - Returning the fallbackValue if provided in the interpolation parameters * - Logging missing translations for debugging purposes * - Returning the translation key as a fallback when no fallbackValue is available */ declare class HsMissingTranslationHandler implements MissingTranslationHandler { handle(params: MissingTranslationHandlerParams): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Custom loader for translations that works with webpack. * It loads translation files from the assets folder and merges them with any overrides. */ declare class HsTranslateLoader implements TranslateLoader { /** * Map to keep track of loaded languages */ loadedLanguages: i0.WritableSignal>; /** * List of languages loaded using APP_INITIALIZER token * Considered as fully loaded from the start eg. no reload is necessary to load translation overrides */ loadedViaInitializer: string[]; private hsConfig; private hsLog; private httpClient; /** * Loads the translations for a given language. * @param lang - language code in ISO 639-1 format such as `en` * @returns An Observable of the translation object for the specified language */ getTranslation(lang: string): Observable; /** * Validates that the assets path is set in the configuration. * Retries up to 10 times with a 100ms interval if the path is not set - basically waits for config update. * @returns An Observable of the assets path or an error if not set after retries */ private validateAssetsPath; /** * Loads translations for a specific language from the assets folder * and merges them with any overrides specified in the configuration. * @param lang - The language code to load translations for * @returns An Observable of the merged translations */ private loadTranslations; /** * Handles errors that occur when loading translation files. * @param error - The error object from the HTTP request * @param lang - The language code for which the error occurred * @returns An Observable of an empty object for 404 errors with additional languages, or throws an error otherwise */ private handleTranslationError; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { HsLanguageService, HsMissingTranslationHandler, HsTranslateLoader };