Skip to content

Conversation

@Robot-Inventor
Copy link
Contributor

Why?

Some browsers send only regional tags like ja-JP in the Accept-Language header. When no exact match exists, the current behavior can fail to detect a supported base language, leading to missed localization.

What?

Allow language detection to fall back from a regional tag (e.g., ja-JP) to its base tag (ja) when the exact match is not supported.

How?

While parsing Accept-Language, check for an exact match in acceptedLanguages, and if none is found, split on - and try the base language tag before giving up.

matching

\### Why?

Some browsers send only regional tags like `ja-JP` in the
`Accept-Language` header. When no exact match exists, the current
behavior can fail to detect a supported base language, leading to missed
localization.

\### What?

Allow language detection to fall back from a regional tag (e.g.,
`ja-JP`) to its base tag (`ja`) when the exact match is not supported.

\### How?

While parsing `Accept-Language`, check for an exact match in
`acceptedLanguages`, and if none is found, split on `-` and try the base
language tag before giving up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant