Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(lang): respect fallback languages #938

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

sorin-davidoi
Copy link
Contributor

If navigator.languages returns ['da', 'en-US', 'en'], and the Danish language is not available, the user interface should be in English.

Currently it is shown in Norwegian, because only 'da' is taken into account when deciding on the preferred language (and match selects nb-NO using the default 'best fit' algorithm).

While the Norwegian and Danish languages are similar, I would argue that this is a bug, as navigator.languages cleary states that the fallback language should be English.

Another potential solution would be to pass { algorithm: 'lookup' } to the match function. However, this might break some cases when a 'best fit' approach would be appropriate (e.g. Swiss German falling back to German).

See https://helvede.net/@jwcph/113497955274343365.

@sorin-davidoi sorin-davidoi force-pushed the lang-respect-fallbacks branch 3 times, most recently from a78dbaf to 405833d Compare November 18, 2024 22:57
If `navigator.languages` returns `['da', 'en-US', 'en']`, and the Danish
language is not available, the user interface should be in English.

Currently it is shown in Norwegian, because only `'da'` is taken into
account when deciding on the preferred language (and `match` selects
`nb-NO` using the default `'best fit'` algorithm).

While the Norwegian and Danish languages are similar, I would argue that
this is a bug, as `navigator.languages` cleary states that the fallback
language should be English.

Another potential solution would be to pass `{ algorithm: 'lookup' }` to
the `match` function. However, this might break some cases when a
`'best fit'` approach would be appropriate (e.g. Swiss German falling
back to German).

See https://helvede.net/@jwcph/113497955274343365.
@cheeaun cheeaun added bug Something isn't working i18n labels Nov 19, 2024
@cheeaun cheeaun merged commit 2e83df6 into cheeaun:main Nov 19, 2024
6 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working i18n
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants