jmoenig/Snap

default to browser language

Opened this issue · 4 comments

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

It's not even all that hard to do

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

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"])

(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)

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