@bespunky/angular-zen
Version:
The Angular tools you always wished were there.
51 lines (50 loc) • 2.5 kB
TypeScript
import { UrlReflectionService } from '@bespunky/angular-zen/router-x';
import { UrlLocalizationConfig } from '../config/url-localization-config';
import { UrlLocalizer } from '../localizers/url-localizer';
import * as i0 from "@angular/core";
/**
* Provides tools for localization and delocalization of the currently navigated url taking into
* account the url localization configuration provided when importing the language integration module.
*
* @export
* @class UrlLocalizationService
*/
export declare class UrlLocalizationService {
private config;
private urlReflection;
readonly localizer: UrlLocalizer;
/**
* Creates an instance of UrlLocalizationService.
*
* @param {UrlLocalizationConfig} config The url localization configuration provided for the `UrlLocalization` token.
* @param {UrlReflectionService} urlReflection The url reflection service.
* @param {UrlLocalizer} localizer The url localizer which will actually do the localization work.
* The instance and implementation depend on the strategy configured for url localization when importing the language integration module.
*/
constructor(config: UrlLocalizationConfig, urlReflection: UrlReflectionService, localizer: UrlLocalizer);
/**
* Localizes the currently navigated url using the configured localization strategy and forces https if needed.
*
* @param {string} lang The langugae to localize the currently navigated url to.
* @returns {string} The localized currently navigated url.
*/
localize(lang: string): string;
/**
* Delocalizes the currently navigated url using the configured localization strategy and forces https if needed.
*
* @returns {string} The delocalized currently navigated url.
*/
delocalize(): string;
/**
* Generates a localized version of the currently navigate url for each of the specified languages using the configured localization strategy.
*
* @param {string[]} langs The languages for which to generate the localized urls.
* @returns {{ [lang: string]: string }[]} An array of { [lang]: url } containing an object for each language and its corresponding localized url.
*/
generateLocalizedUrls(langs: string[]): {
[lang: string]: string;
}[];
private replaceHttpIfRequired;
static ɵfac: i0.ɵɵFactoryDeclaration<UrlLocalizationService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<UrlLocalizationService>;
}