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

Match more specific locales to supported ones #1241

Merged
merged 2 commits into from
Jun 16, 2023
Merged

Match more specific locales to supported ones #1241

merged 2 commits into from
Jun 16, 2023

Conversation

MageJohn
Copy link
Contributor

Fixes #1205

I noticed that the linked issue could be solved by the nonExplicitSupportedLngs setting for i18next (see here), but the existing system for choosing the language bypassed the i18next code where that setting applied. Therefore I moved the code for getting languages into a simple languageDetector plugin for i18next.

For reference on these plugins, I used the docs and the source of the package i18next-browser-languagedetector.

I was then able to simplify some other code that references the current language by referring to the value tracked by i18next.

I've tested the code locally to confirm that the issue is resolved. I tested using a browser language order of ["en-GB", "nl", "en-US", "en"]. The behaviour without my changes is to show the site in Dutch (it skipped "en-GB" and found "nl"). The behaviour with my changes is to show the site in English (it recognises that "en" strings are suitable for the "en-GB" locale).

To do this, replace the current system for choosing the language with one that makes use of i18next features.
@MageJohn
Copy link
Contributor Author

MageJohn commented Jun 15, 2023

Rebased onto latest main

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thx!

@dessalines dessalines merged commit 882efe1 into LemmyNet:main Jun 16, 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 this pull request may close these issues.

Lemmy is showing in a different language than my browser's and OS's
3 participants