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

default to browser language #3355

Open
2-www opened this issue May 12, 2024 · 4 comments
Open

default to browser language #3355

2-www opened this issue May 12, 2024 · 4 comments

Comments

@2-www
Copy link
Contributor

2-www commented May 12, 2024

by default, snap opens in english, it can be changed, but i think it would be better to load the system language by default

@ego-lay-atman-bay
Copy link
Contributor

It's not even all that hard to do

var lang = navigator.language || navigator.userLanguage;

@2-www
Copy link
Contributor Author

2-www commented May 12, 2024

navigator.language returns the most preferred language including the country code, it's better use the 1st supported code from navigator.languages instead. (example: navigator.languages == ["uk-UA", "uk", "en-US", "en"])

@2-www
Copy link
Contributor Author

2-www commented May 12, 2024

(yes, the current code in snap is SnapTranslator.dict.ua = {, but the official short code for ukranian is uk, which is what browsers report, so that would also need to be changed for the feature to work in ukrainian)

@2-www
Copy link
Contributor Author

2-www commented May 12, 2024

also i found out that apple webkit only shows 1 entry in that array, no matter what, for security reasons:
https://bugs.webkit.org/show_bug.cgi?id=247308#c3

so web apps have to try stripping the language code themselves

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

No branches or pull requests

2 participants