diff --git a/orangepi-server/static/app.js b/orangepi-server/static/app.js
index fd15361..10036fa 100644
--- a/orangepi-server/static/app.js
+++ b/orangepi-server/static/app.js
@@ -151,21 +151,21 @@ const MAP = {
const $ = (sel) => document.querySelector(sel);
const $$ = (sel) => document.querySelectorAll(sel);
-function t(key) {
+function i18n(key) {
return I18N[State.lang][key] || I18N.en[key] || key;
}
function applyI18n() {
document.documentElement.lang = State.lang;
document.body.dataset.lang = State.lang;
- document.title = t("page_title");
+ document.title = i18n("page_title");
$$("[data-i18n]").forEach(el => {
const k = el.getAttribute("data-i18n");
- el.textContent = t(k);
+ el.textContent = i18n(k);
});
$$("[data-i18n-title]").forEach(el => {
const k = el.getAttribute("data-i18n-title");
- el.title = t(k);
+ el.title = i18n(k);
});
}
@@ -384,7 +384,7 @@ function drawZones(zones) {
ctx.save();
ctx.font = "bold 11px 'Inter', system-ui, sans-serif";
ctx.textAlign = "center";
- const occText = z.occupied ? t("occupied") : t("empty");
+ const occText = z.occupied ? i18n("occupied") : i18n("empty");
ctx.fillStyle = z.occupied ? "#ffffff" : hexToRgba("#000000", 0.55);
const label = `Z${z.id} · ${occText}`;
const metrics = ctx.measureText(label);
@@ -591,13 +591,13 @@ function refreshPanels() {
row.innerHTML = `
T${t.slot}
-
${t(statusKey)}
+
${i18n(statusKey)}
-
${t("x_coord")}: ${t.x_mm} mm
-
${t("y_coord")}: ${t.y_mm} mm
-
${t("speed")}: ${speedTxt} cm/s
-
${t("distance")}: ${distanceKm} m
-
${t("angle")}: ${angleTxt}
+
${i18n("x_coord")}: ${t.x_mm} mm
+
${i18n("y_coord")}: ${t.y_mm} mm
+
${i18n("speed")}: ${speedTxt} cm/s
+
${i18n("distance")}: ${distanceKm} m
+
${i18n("angle")}: ${angleTxt}
`;
tl.appendChild(row);
@@ -612,10 +612,10 @@ function refreshPanels() {
row.innerHTML = `
-
${t("zone_"+(idx+1))} · Z${z.id}
+
${i18n("zone_"+(idx+1))} · Z${z.id}
[${z.x1}, ${z.y1}] → [${z.x2}, ${z.y2}]
- ${z.occupied ? t("occupied") : t("empty")}
+ ${z.occupied ? i18n("occupied") : i18n("empty")}
`;
zl.appendChild(row);
});
@@ -629,22 +629,22 @@ function buildEditorInputs() {
const block = document.createElement("div");
block.className = "zone-editor-block";
block.innerHTML = `
-
+
`;
@@ -719,7 +719,7 @@ function connectWS() {
console.warn("[Radar] WebSocket closed (code=" + ev.code + " reason=" + ev.reason + ")");
State.browserWsConnected = false;
updateWsStatus("err");
- if (wsReconnectTimer == null) toast(t("ws_reconnecting"), "warning");
+ if (wsReconnectTimer == null) toast(i18n("ws_reconnecting"), "warning");
scheduleReconnect();
};
_activeWs.onerror = (ev) => {
@@ -741,14 +741,14 @@ function updateWsStatus(kind) {
const dot = chip.querySelector(".status-dot");
const txt = chip.querySelector("span:last-child");
dot.className = "status-dot " + (kind === "ok" ? "status-ok" : kind === "err" ? "status-err" : "status-warn");
- txt.textContent = kind === "ok" ? t("ws_connected") : kind === "err" ? t("ws_disconnected") : t("ws_connecting");
+ txt.textContent = kind === "ok" ? i18n("ws_connected") : kind === "err" ? i18n("ws_disconnected") : i18n("ws_connecting");
}
function updateEsp32Status(connected) {
const chip = $("#statusEsp32");
const dot = chip.querySelector(".status-dot");
const txt = chip.querySelector("span:last-child");
dot.className = "status-dot " + (connected ? "status-ok" : "status-err");
- txt.textContent = connected ? t("esp32_connected") : t("esp32_disconnected");
+ txt.textContent = connected ? i18n("esp32_connected") : i18n("esp32_disconnected");
}
/* Called on every broadcast frame from backend */
@@ -851,11 +851,11 @@ function initUI() {
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error("HTTP " + res.status);
- toast(t("zone_saved"), "success");
+ toast(i18n("zone_saved"), "success");
$("#zoneEditor").hidden = true;
} catch (err) {
console.error(err);
- toast(t("zone_save_error") + ": " + err.message, "error");
+ toast(i18n("zone_save_error") + ": " + err.message, "error");
}
});