feat(i18n): dynamic locale loading + Weblate setup (#71) #77
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/i18n-dynamic-locales"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the groundwork for the Weblate translation workflow requested in #71.
Why
Adding a language used to require editing three things: the JSON file,
supportedLanguagesinfrontend/src/i18n/index.ts, andSupportedLanguagesininternal/i18n/catalog.go. Those two hardcoded lists were the only thing preventing a no-code, Weblate-driven workflow.Changes
SupportedLanguagesis now derived from the embedded locale files via a newdiscoverLanguages(fs.FS)that globslocales/*.json(sorted; falls back to the default language if none exist).import.meta.glob('../../../locales/*.json'); both the i18nextresourcesand the language picker are built from that. Picker labels come fromIntl.DisplayNames(the language's own name, e.g. "Deutsch").docs/i18n.md): "adding a language" is now just dropping in a JSON file; added a Weblate section with the exact component config (file masklocales/*.json, monolingual baselocales/en.json, formati18next JSON, sourceen) and the Forgejo webhook note.After this, dropping a new
locales/<code>.jsoninto the repo is enough for it to be served by the API and appear in the UI picker — exactly what a Weblate component produces.Tests
discoverLanguagesunit tests (sorted,.json-only, empty-FS fallback) viafstest.MapFS.SupportedLanguagesis derived from the bundle (still includes en+de).go test ./...,go vet, frontendpnpm lint+pnpm buildall pass.What still needs you (server-side)
Steps 1 and 3 are done in this PR. Step 2 — provisioning the actual Weblate instance, creating the component against this repo, and adding the Forgejo webhook — needs your Weblate server; the exact settings are in
docs/i18n.md. If you give me the Weblate host URL I can create the Forgejo webhook via the API.Refs #71.
🤖 Generated with Claude Code