diff --git a/webui/i18n.js b/webui/i18n.js index 9619f1d..c53fb5e 100644 --- a/webui/i18n.js +++ b/webui/i18n.js @@ -1128,6 +1128,16 @@ window.O2I18N = (() => { return ""; } }; + const browserLocale = () => { + const candidates = [...(navigator.languages || []), navigator.language].filter(Boolean); + for (const candidate of candidates) { + const normalized = String(candidate).toLowerCase(); + if (normalized.startsWith('zh')) return 'zh-CN'; + if (normalized.startsWith('vi')) return 'vi'; + if (normalized.startsWith('en')) return 'en'; + } + return ''; + }; const init = () => { document.documentElement.lang = locale; @@ -1143,7 +1153,8 @@ window.O2I18N = (() => { ); node.onchange = (event) => setLocale(event.target.value); }); - if (SUPPORTED.includes(stored())) setLocale(stored(), false); + const initial = SUPPORTED.includes(stored()) ? stored() : browserLocale(); + if (initial) setLocale(initial, false); else apply(); syncSelectors(); }; diff --git a/webui/index.html b/webui/index.html index 0b0a4d1..afbd23e 100644 --- a/webui/index.html +++ b/webui/index.html @@ -105,7 +105,7 @@
diff --git a/webui/styles.css b/webui/styles.css index 8c2cb1a..e585eb4 100644 --- a/webui/styles.css +++ b/webui/styles.css @@ -318,9 +318,12 @@ pre, display: inline-flex; align-items: center; justify-content: center; - width: auto; + width: 34px; min-width: 34px; + max-width: 34px; + flex: 0 0 34px; height: 38px; + overflow: hidden; padding: 0 4px; border: 0; background: transparent; @@ -948,3 +951,19 @@ textarea { max-width: 270px; overflow-wrap: anywhere; } + + +.toolbar { + padding-right: 40px; + position: relative; +} + +.app-lang { + position: absolute; + right: 0; + top: 50%; + transform: translateY(-50%); + z-index: 20; +} + +.login-lang { display: none !important; }