diff --git a/webui/i18n.js b/webui/i18n.js
index 4a42bcd..0c3aff0 100644
--- a/webui/i18n.js
+++ b/webui/i18n.js
@@ -20,32 +20,10 @@ window.O2I18N = (() => {
// Snapshot of the authored copy, so switching back restores it untouched.
const originals = new WeakMap();
- // Inline vector flags. Unicode flag emoji degrades to letters on Windows and
- // emoji assets would need an extra request, so every flag is drawn in a 60x30
- // viewBox and scaled by CSS.
- const FLAG_ART = {
- "zh-CN":
- '' +
- '',
- vi:
- '' +
- '',
- en:
- '' +
- '' +
- '' +
- '' +
- '',
- };
-
- const flagIcon = (code) =>
- ``;
-
const DICTIONARY = {
en: {
"doc.title": "opencode2api · Operations Handbook",
"lang.label": "Language",
- "lang.menu": "Choose a language",
"login.eyebrow": "Admin operations handbook / 2026",
"login.headline": "Bring protocols, routing, and runtime state onto one desk.",
@@ -560,7 +538,6 @@ window.O2I18N = (() => {
vi: {
"doc.title": "opencode2api · Sổ tay vận hành",
"lang.label": "Ngôn ngữ",
- "lang.menu": "Chọn ngôn ngữ",
"login.eyebrow": "Sổ tay vận hành dành cho quản trị / 2026",
"login.headline": "Đưa giao thức, định tuyến và trạng thái vận hành lên cùng một bàn.",
@@ -1117,43 +1094,10 @@ window.O2I18N = (() => {
});
};
- const closeMenus = (except) =>
- document.querySelectorAll("[data-lang]").forEach((host) => {
- if (host === except) return;
- const menu = host.querySelector("[data-lang-menu]");
- if (menu) menu.hidden = true;
- const button = host.querySelector("[data-lang-toggle]");
- if (button) button.setAttribute("aria-expanded", "false");
- });
-
- const syncControls = () => {
- document.querySelectorAll("[data-lang]").forEach((host) => {
- const button = host.querySelector("[data-lang-toggle]");
- const menu = host.querySelector("[data-lang-menu]");
- if (button) {
- const label = `${t("语言", "lang.label")}: ${LABELS[locale]}`;
- button.innerHTML = flagIcon(locale);
- button.title = label;
- button.setAttribute("aria-label", label);
- }
- if (menu) {
- menu.replaceChildren(
- ...SUPPORTED.map((code) => {
- const option = document.createElement("button");
- option.type = "button";
- option.className = "lang-option";
- option.dataset.locale = code;
- option.setAttribute("aria-current", String(code === locale));
- option.append(...[flagIcon(code), document.createTextNode(LABELS[code])]);
- option.onclick = () => {
- menu.hidden = true;
- button?.setAttribute("aria-expanded", "false");
- setLocale(code);
- };
- return option;
- }),
- );
- }
+ const syncSelectors = () => {
+ document.querySelectorAll("[data-lang-switch]").forEach((node) => {
+ node.value = locale;
+ node.setAttribute("aria-label", t("语言", "lang.label"));
});
};
@@ -1172,7 +1116,7 @@ window.O2I18N = (() => {
document.documentElement.lang = locale;
apply();
}
- syncControls();
+ syncSelectors();
if (changed) notify();
};
@@ -1186,25 +1130,20 @@ window.O2I18N = (() => {
const init = () => {
document.documentElement.lang = locale;
- document.querySelectorAll("[data-lang]").forEach((host) => {
- const button = host.querySelector("[data-lang-toggle]");
- const menu = host.querySelector("[data-lang-menu]");
- if (!button || !menu) return;
- button.onclick = (event) => {
- event.stopPropagation();
- const open = menu.hidden;
- closeMenus(host);
- menu.hidden = !open;
- button.setAttribute("aria-expanded", String(open));
- };
- });
- document.addEventListener("click", () => closeMenus(null));
- document.addEventListener("keydown", (event) => {
- if (event.key === "Escape") closeMenus(null);
+ document.querySelectorAll("[data-lang-switch]").forEach((node) => {
+ node.replaceChildren(
+ ...SUPPORTED.map((code) => {
+ const option = document.createElement("option");
+ option.value = code;
+ option.textContent = LABELS[code];
+ return option;
+ }),
+ );
+ node.onchange = (event) => setLocale(event.target.value);
});
if (SUPPORTED.includes(stored())) setLocale(stored(), false);
else apply();
- syncControls();
+ syncSelectors();
};
return {
diff --git a/webui/index.html b/webui/index.html
index 59c0ab7..5a6945e 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -21,24 +21,7 @@