feat(api): localize console pages and api error messages

The language comes from the user setting, then the lang cookie, then
Accept-Language, falling back to English. Errors keep a stable code and
carry a translated message.

Closes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:07:00 +01:00
1 parent dde7b890b8
commit 70190446ff
12 files changed
+698 -211

No files matched your search

+23 -15
View File
@@ -1,37 +1,45 @@
package web
import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
templ Login(p Page, signupAllowed bool) {
@authShell(p, "Anmelden") {
@authShell(p) {
<form data-api="/auth/login" data-next="/">
@formError()
<div data-step="password">
@field("E-Mail", "email", "email", "username", true)
@field("Passwort", "password", "password", "current-password", true)
@field(i18n.T(ctx, "auth.field.email"), "email", "email", "username", true)
@field(i18n.T(ctx, "auth.field.password"), "password", "password", "current-password", true)
</div>
<div data-step="totp" hidden>
<p class="mb-4 text-sm text-muted">Code aus der Authenticator-App eingeben.</p>
@field("Code", "code", "text", "one-time-code", false)
<p class="mb-4 text-sm text-muted">{ i18n.T(ctx, "auth.login.totp_hint") }</p>
@field(i18n.T(ctx, "auth.field.code"), "code", "text", "one-time-code", false)
</div>
@submit("Weiter")
@submit(i18n.T(ctx, "auth.login.submit"))
</form>
if signupAllowed {
<p class="mt-8 text-sm text-muted">Noch kein Konto? <a class="text-ink underline underline-offset-2" href="/signup">Registrieren</a></p>
<p class="mt-8 text-sm text-muted">
{ i18n.T(ctx, "auth.login.no_account") }
<a class="text-ink underline underline-offset-2" href="/signup">{ i18n.T(ctx, "auth.login.to_signup") }</a>
</p>
}
}
}
templ Signup(p Page) {
@authShell(p, "Konto anlegen") {
@authShell(p) {
<form data-api="/auth/signup" data-next="/">
@formError()
@field("Name", "display_name", "text", "name", false)
@field("E-Mail", "email", "email", "username", true)
@field("Passwort (min. 12 Zeichen)", "password", "password", "new-password", true)
@field(i18n.T(ctx, "auth.field.name"), "display_name", "text", "name", false)
@field(i18n.T(ctx, "auth.field.email"), "email", "email", "username", true)
@field(i18n.T(ctx, "auth.field.new_password", "Min", auth.MinPasswordLength), "password", "password", "new-password", true)
<hr class="my-6 border-rule"/>
@field("Organisation", "org_name", "text", "organization", true)
@field("Kurzname (a–z, 0–9, -)", "org_slug", "text", "off", true)
@submit("Anlegen")
@field(i18n.T(ctx, "auth.field.org_name"), "org_name", "text", "organization", true)
@field(i18n.T(ctx, "auth.field.org_slug"), "org_slug", "text", "off", true)
@submit(i18n.T(ctx, "auth.signup.submit"))
</form>
<p class="mt-8 text-sm text-muted"><a class="text-ink underline underline-offset-2" href="/login">Zur Anmeldung</a></p>
<p class="mt-8 text-sm text-muted"><a class="text-ink underline underline-offset-2" href="/login">{ i18n.T(ctx, "auth.signup.to_login") }</a></p>
}
}