Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate Mapping for Locales #227

Open
JE4GLE opened this issue May 23, 2023 · 0 comments · May be fixed by #229
Open

Alternate Mapping for Locales #227

JE4GLE opened this issue May 23, 2023 · 0 comments · May be fixed by #229

Comments

@JE4GLE
Copy link

JE4GLE commented May 23, 2023

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.

This was referenced May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant