The portal in English and Turkish: a catalogue per language, a switcher at the foot of every page, landing.language, Turkish numbers and dates

Every template and handler message in internal/web goes through a JSON
catalogue under internal/web/locales/<code>/, with English as the fallback.
The language is the person's choice (a cookie set by /_lang/{code}), else
Accept-Language, else landing.language. Tests refuse a key some language
lacks, a translation with other arguments than English, and template text
left in English.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 00:12:53 +02:00
1 parent 30f7f3474a
commit 11231d8c2b
113 files changed
+8091 -1981

No files matched your search

+13 -8
View File
@@ -3,6 +3,7 @@ package web
import (
"context"
"fmt"
"html/template"
"log/slog"
"net/http"
"sort"
@@ -26,6 +27,8 @@ type nodePageData struct {
Self string
Version, Now string
RefreshSec int
// RefreshMeta is the reload for a browser without script.
RefreshMeta template.HTML
}
// nodeEngine is one engine running on the node, and its share of it.
@@ -96,9 +99,10 @@ func NodePage(src Source, history History, window time.Duration, onAdminListener
d := nodePageData{
Nav: navFrom(r, "cluster"), OnAdminListener: onAdminListener,
Back: "/admin", Logs: "/admin/nodes/" + id + "/logs", Self: "/admin/nodes/" + id,
HasHistory: history != nil, Version: version, RefreshSec: 15,
HasHistory: history != nil, Version: version, RefreshSec: 15, RefreshMeta: refreshMeta(15),
Now: time.Now().UTC().Format(time.RFC3339),
}
l := langOf(r)
if onAdminListener {
d.Back, d.Logs, d.Self = "/", "/nodes/"+id+"/logs", "/nodes/"+id
}
@@ -106,6 +110,7 @@ func NodePage(src Source, history History, window time.Duration, onAdminListener
for _, n := range src.Nodes() {
if n.ID == id {
d.Node, found = n, true
d.Node.LastSeenAgo = l.clockText(n.LastSeenAgo)
break
}
}
@@ -134,18 +139,18 @@ func NodePage(src Source, history History, window time.Duration, onAdminListener
sort.Slice(d.Engines, func(i, j int) bool { return d.Engines[i].CPUCores > d.Engines[j].CPUCores })
if history != nil {
d.Charts = loadNodeCharts(r.Context(), history, id, replicas, d.Node.GPUTotal, window, log)
d.Charts = loadNodeCharts(r.Context(), l, history, id, replicas, d.Node.GPUTotal, window, log)
}
noStore(w)
render(w, "node", d)
render(w, r, "node", d)
}
}
func loadNodeCharts(ctx context.Context, h History, node string, replicas []string, gpus int,
func loadNodeCharts(ctx context.Context, l *Lang, h History, node string, replicas []string, gpus int,
window time.Duration, log *slog.Logger,
) *nodeCharts {
step := window / 60
out := &nodeCharts{Window: windowWord(window)}
out := &nodeCharts{Window: l.windowWord(window)}
quoted := fmt.Sprintf("%q", node)
for _, p := range nodePanels {
series, err := h.RangeQuery(ctx, fmt.Sprintf(p.expr, quoted), p.nameBy, window, step)
@@ -156,7 +161,7 @@ func loadNodeCharts(ctx context.Context, h History, node string, replicas []stri
out.Err = err.Error()
return out
}
p.into(out, LineChart(series, p.unit, 4))
p.into(out, l.LineChart(series, p.unit, 4))
}
// Every card its own line, up to the eight a node commonly has.
if gpus > 0 {
@@ -168,7 +173,7 @@ func loadNodeCharts(ctx context.Context, h History, node string, replicas []stri
for i := range series {
series[i].Name = "GPU " + series[i].Name
}
p.into(out, LineChart(series, p.unit, max(gpus, 8)))
p.into(out, l.LineChart(series, p.unit, max(gpus, 8)))
}
}
// The engines' queues, for the replicas that are here now.
@@ -179,7 +184,7 @@ func loadNodeCharts(ctx context.Context, h History, node string, replicas []stri
}
expr := fmt.Sprintf(`llmgw_endpoint_waiting{replica=~%q}`, strings.Join(re, "|"))
if series, err := h.RangeQuery(ctx, expr, "replica", window, step); err == nil {
out.Queue = LineChart(series, "", 4)
out.Queue = l.LineChart(series, "", 4)
}
}
return out