The app's own pages in the server's nine languages
scripts/gen-i18n.py writes ui/i18n.js from the server's catalogues where the same sentence exists and from its own table otherwise; the pages pick the language from the browser and fall back to English. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
7 files changed
+1175
-58
No files matched your search
+18
-14
@@ -1,6 +1,7 @@
|
||||
// The title bar. Moving and double-click maximising come from `data-tauri-drag-region`; the
|
||||
// buttons call the window directly; the menu and the agent pill open the app's native menu (the
|
||||
// tray's items), which can reach past this 36-pixel-high page.
|
||||
// tray's items), which can reach past this 36-pixel-high page. The bar is painted in the theme
|
||||
// the app reports in `status` (the server page's); every word goes through `t` (i18n.js).
|
||||
"use strict"
|
||||
|
||||
const { invoke } = window.__TAURI__.core
|
||||
@@ -10,16 +11,17 @@ const win = window.__TAURI__.window.getCurrentWindow()
|
||||
const $ = (id) => document.getElementById(id)
|
||||
|
||||
const WORDS = {
|
||||
off: "agent off",
|
||||
not_linked: "not linked",
|
||||
starting: "agent starting…",
|
||||
running: "agent running",
|
||||
elsewhere: "agent running (service)",
|
||||
failed: "agent stopped",
|
||||
no_folders: "agent: no folders",
|
||||
off: () => t("agent off"),
|
||||
not_linked: () => t("not linked"),
|
||||
starting: () => t("agent starting…"),
|
||||
running: () => t("agent running"),
|
||||
elsewhere: () => t("agent running (service)"),
|
||||
failed: () => t("agent stopped"),
|
||||
no_folders: () => t("agent: no folders"),
|
||||
}
|
||||
|
||||
function render(s) {
|
||||
window.lembasTheme.apply(s.theme)
|
||||
let host = ""
|
||||
try {
|
||||
host = s.server ? new URL(s.server).host : ""
|
||||
@@ -30,18 +32,20 @@ function render(s) {
|
||||
const noFolders = s.remote && !(s.remote.enabled && s.remote.roots.length)
|
||||
const state = s.agent.state === "running" && noFolders ? "no_folders" : s.agent.state
|
||||
$("agent").dataset.state = state
|
||||
$("agent-text").textContent = WORDS[state] ?? state
|
||||
$("agent").title = state === "failed" ? `Agent stopped: ${s.agent.detail}` : "Agent"
|
||||
$("agent-text").textContent = WORDS[state] ? WORDS[state]() : state
|
||||
$("agent").title = state === "failed" ? t("Agent stopped: %(why)s", { why: s.agent.detail }) : t("Agent")
|
||||
$("update").hidden = !s.update
|
||||
$("update").textContent = s.update ? `update ${s.update}` : "update"
|
||||
$("update").title = s.update ? `LLeMbas ${s.update} is available (this is ${s.version})` : ""
|
||||
$("update").textContent = s.update ? t("update %(version)s", { version: s.update }) : t("update")
|
||||
$("update").title = s.update
|
||||
? t("LLeMbas %(version)s is available (this is %(current)s)", { version: s.update, current: s.version })
|
||||
: ""
|
||||
}
|
||||
|
||||
function maximized(on) {
|
||||
const b = $("maximize")
|
||||
b.toggleAttribute("data-maximized", on)
|
||||
b.setAttribute("aria-label", on ? "Restore" : "Maximise")
|
||||
b.title = on ? "Restore" : "Maximise"
|
||||
b.setAttribute("aria-label", on ? t("Restore") : t("Maximise"))
|
||||
b.title = on ? t("Restore") : t("Maximise")
|
||||
}
|
||||
|
||||
$("minimize").addEventListener("click", () => win.minimize())
|
||||
|
||||
Reference in new issue
Block a user