jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.5k stars 744 forks source link

default to browser language #3355

Open 2-www opened 4 months ago

2-www commented 4 months ago

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 commented 4 months ago

It's not even all that hard to do

var lang = navigator.language || navigator.userLanguage;
2-www commented 4 months ago

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 commented 4 months ago

(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 commented 4 months ago

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