UNPKG

@bespunky/angular-zen

Version:

The Angular tools you always wished were there.

74 lines (73 loc) 3.13 kB
import { UrlTree } from '@angular/router'; import { UrlReflectionService } from '@bespunky/angular-zen/router-x'; import { UrlLocalizationConfig } from '../config/url-localization-config'; import { UrlLocalizer } from './url-localizer'; import * as i0 from "@angular/core"; /** * Provides tools for localization and delocalization of the currently navigated url by adding or removing * a named query param dedicated for language. * * @export * @class QueryParamsUrlLocalizer * @extends {UrlLocalizer} */ export declare class QueryParamsUrlLocalizer extends UrlLocalizer { /** * The name of the query parameter specifying the language. * * @type {string} */ readonly paramName: string; constructor({ strategy }: UrlLocalizationConfig, urlReflection: UrlReflectionService); /** * Localizes the currently navigated url by adding or updating the query param specifying the language. * * @param {string} lang The new language of the url. * @returns {string} The currently navigated url localized into the specified language. */ localize(lang: string): string; /** * Delocalizes the currently navigated url by removing the query param specifying the language. * * @returns {string} The currently navigated url without the query param for language. */ delocalize(): string; /** * Returns the `UrlTree` representing the currently navigated url. * * @protected * @returns {UrlTree} The `UrlTree` representing the currently navigated url. */ protected parseUrlTree(): UrlTree; /** * Updates the language param in a query params object. * * @protected * @param {*} params The object representing the query params. * @param {string} lang The new language to set to the language query param. If `null` or `undefined`, the language query param will be deleted from the object. * @returns {*} The updated query params object. */ protected replaceLanguageParam(params: any, lang: string): any; /** * Replaces the query params in a url tree object. * * @protected * @param {UrlTree} url The url tree in which query params should be replaced. * @param {Object} newParams The new query params object to set to the url tree. * @returns {UrlTree} The updated url tree object. */ protected replaceQueryParamsInUrlTree(url: UrlTree, newParams: { [k: string]: any; }): UrlTree; /** * Concats the host url and the specified route url to compose a fully qualified url. * Uses the host url provided by the url reflection service. * * @protected * @param {string} routeUrl The route url to concat to the host url. Should be prefixed with '/'. * @returns {string} The fully qualified url composed of the host url defined by the url reflection service and the specified route url. */ protected composeUrl(routeUrl: string): string; static ɵfac: i0.ɵɵFactoryDeclaration<QueryParamsUrlLocalizer, never>; static ɵprov: i0.ɵɵInjectableDeclaration<QueryParamsUrlLocalizer>; }