Alternate Mapping for Locales
Opened this issue · 0 comments
I have my locales configured as follows:
lunetics_locale:
strict_mode: false
strict_match: true
allowed_locales:
- de_DE
- en_US
I'm using the xx_XX
format instead of xx
, because I might want to create separate versions for en_US
and en_GB
later. This format is commonly used in computing environments to adapt software to the user's linguistic, cultural, and regional preferences. It can influence the formatting of dates, numbers, currency, and more, as well as the language used for text display in user interfaces.
Unfortunately, this doesn't allow for locales like en
being detected. In this case, the default (de_DE
) is used.
I'm also relying on strict_match
, because my application only supports the defined locales.
My request is the following:
If there is no exact mapping available, match only the first part.
// Not match found
if (strpos($locale, '_') !== false) {
$newLocale = explode('_', $locale)[0];
// Retry with $newLocale
}
** Another solution would be:**
Add a map of locales, which can serve as a mapping. For example:
lunetics_locale:
...
locale_mapping:
de: de_DE
en: en_US
This would allow en
and en_XX
being redirected to en_US
.