URL To Locale Map
⚠️ This functionality is not available to single page applications or any website where changing the language does not trigger a full page reload.
Deriving the locale from the page URL
The widget locale
can be derived from the page URL when urlToLocaleMap
is defined in config.
When a match is found between the current page URL and any key in the urlToLocaleMap
, the widget will use the corresponding locale. If no match is found, the widget falls back to the locale
specified in config.
Configuration
The urlToLocaleMap
is an object where:
- Keys are part of the url that safely indentify the language
- Values are the corresponding locale codes that are supported by DigitalGenius, see the language documentation for a list of supported locales.
Examples
Country-specific domain
https://example.fr/products → fr-FR
https://example.de/products → de-DE
{
"urlToLocaleMap": {
"https://example.fr": "fr-FR",
"https://example.de": "de-DE",
}
}
Subdomains
https://fr.example.com/products → fr-FR
https://de.example.com/products → de-DE
{
"urlToLocaleMap": {
"https://fr.example.com": "fr-FR",
"https://de.example.com": "de-DE",
}
}
Sub directory
https://example.com/fr/products → fr-FR
https://example.com/de/products → de-DE
{
"urlToLocaleMap": {
"https://example.com/fr/": "fr-FR",
"https://example.com/de/": "de-DE",
}
}
Updated 6 days ago