Provides tools for localization and delocalization of the currently navigated url by adding or removing a route segment dedicated for language.
language/src/url-localization/localizers/route-position-url-localizer.ts
Properties |
|
Methods |
|
Accessors |
constructor(undefined: UrlLocalizationConfig, urlReflection: UrlReflectionService, language: LanguageIntegrationService)
|
|||||||||||
Parameters:
|
|||||||||||
Protected accessSegmentsSafely | ||||||||||||
accessSegmentsSafely(segments: string[], accessSegments: () => void)
|
||||||||||||
Accessing segments by index requires the To unify the cases and reduce complexity, when position is negative, this method reverses the segments array, runs the segments manipulation, then reverses it again to restore the original order. This way the indexing is always done from one side of the array.
Parameters:
Returns:
void
|
||||||||||||
Protected composeUrl | ||||||||
composeUrl(segments: string[])
|
||||||||
Concats the host url as given by the url reflection service with the segments and the current query string to create a fully qualified url.
Parameters:
Returns:
string
The fully qualified url composed of the host url as given by the url reflection service, the specified route segments, and the current query params. |
||||||||
delocalize |
delocalize()
|
Inherited from
UrlLocalizer
|
Delocalizes the currently navigated url by removing the language segment from the route.
If ExamplePosition 1 - /en/some/route - first segment from the left. Position 2 - /some/en/route - second segment from the left. Position 5 - /some/route/en - out of bounds. last segment from the left. Position -1 - /some/route/en - first segment from the right. Position -2 - /some/en/route - second segment from the right. Position -5 - /en/some/route - out of bounds. last segment from the right.
Returns:
string
The delocalized currently navigated url. |
Protected indexOfPosition |
indexOfPosition()
|
Calculates the absolute index for the configured language position.
Returns:
number
|
Protected insertOrReplaceLanguage | ||||||||||||||||||||
insertOrReplaceLanguage(lang: string, segments: string[], langIndex: number, isLanguage: boolean)
|
||||||||||||||||||||
Updates the specified route segments array with the specified language.
Parameters:
Returns:
void
|
||||||||||||||||||||
Protected isLanguage | ||||||||
isLanguage(value: string)
|
||||||||
Checks whether the specified value is a language supported by the language integration services.
Parameters:
Returns:
boolean
|
||||||||
localize | ||||||
localize(lang: string)
|
||||||
Inherited from
UrlLocalizer
|
||||||
Localizes the currently navigated url by adding or updating the language segment of the route.
If ExamplePosition 1 - /en/some/route - first segment from the left. Position 2 - /some/en/route - second segment from the left. Position 5 - /some/route/en - out of bounds. last segment from the left. Position -1 - /some/route/en - first segment from the right. Position -2 - /some/en/route - second segment from the right. Position -5 - /en/some/route - out of bounds. last segment from the right.
Parameters:
Returns:
string
The currently navigated url localized to the specified language. |
||||||
Protected removeLanguage | ||||||||||||||||
removeLanguage(segments: string[], langIndex: number, isLanguage: boolean)
|
||||||||||||||||
Removes the language segment from a route segments array. If the language index points to a non-language segment, returns without changing the segments.
Parameters:
Returns:
void
|
||||||||||||||||
Public Readonly position |
Type: number
|
The position of the language segment in the route of the currently navigated url. Positive numbers indicate position from the beginning of the route. Negative numbers indicate position from the end of the route. Zero is ignored and will cause methods to return an unchanged url. |
isPositiveLookup |
getisPositiveLookup()
|
Indicates whether the configured language position is positive, resulting in a lookup from the left (positive lookup).
Returns:
boolean
|
isNegativeLookup |
getisNegativeLookup()
|
Indicates whether the configured language position is negative, resulting in a lookup from the right (negative lookup).
Returns:
boolean
|