feat(quick-261016-0fm): per-admin theme and locale preferences

- GET and PUT /account/preferences (own row only, interactive sessions,
  CSRF header on cookie writes) store admin_theme and admin_locale in
  backend_users.metadata, keeping every other key
- GET /auth/me and the My account answers carry preferences
- phrasebook.Translator.Locales lists the locales defining a prefix
- route tables, conformance cases, OpenAPI document, TS types and docs
This commit is contained in:
Jakub Zych
2026-10-16 09:26:09 +02:00
parent 1a03399357
commit 047858ae84
21 changed files with 729 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"slices"
"strconv"
"strings"
"sync"
@@ -533,6 +534,26 @@ func (t *Translator) Resolved(locale, prefix string) string {
return t.fallbackLocale()
}
// Locales returns the sorted locale codes whose catalog defines at least one
// key starting with prefix: the locales a Bundle under prefix exists in. A
// nil translator or catalog returns nil.
func (t *Translator) Locales(prefix string) []string {
if t == nil || t.cat == nil {
return nil
}
var out []string
for locale, byKey := range t.cat.messages {
for key := range byKey {
if strings.HasPrefix(key, prefix) {
out = append(out, locale)
break
}
}
}
slices.Sort(out)
return out
}
// Has reports whether any locale of the catalog defines key.
func (t *Translator) Has(key string) bool {
if t == nil || t.cat == nil {