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

+7 -7
View File
@@ -96,7 +96,7 @@ func (s *Server) switchOrg(c *gin.Context) {
return
}
}
fail(c, http.StatusNotFound, "org_not_found", "Organisation nicht gefunden.")
fail(c, http.StatusNotFound, "org_not_found")
}
func totpSetupKey(user uuid.UUID) string { return "totp_setup:" + user.String() }
@@ -109,7 +109,7 @@ func (s *Server) totpSetup(c *gin.Context) {
return
}
if me.TOTP {
fail(c, http.StatusConflict, "totp_already_enabled", "TOTP ist bereits aktiv.")
fail(c, http.StatusConflict, "totp_already_enabled")
return
}
key, err := auth.NewTOTPKey(me.Email)
@@ -138,7 +138,7 @@ func (s *Server) totpEnable(c *gin.Context) {
sess := auth.Current(c)
secret, err := s.rdb.Get(ctx, totpSetupKey(sess.UserID)).Result()
if err != nil {
fail(c, http.StatusConflict, "totp_setup_expired", "Einrichtung abgelaufen, bitte neu starten.")
fail(c, http.StatusConflict, "totp_setup_expired")
return
}
if !s.limit(c, "totp_enable:"+sess.UserID.String(), 10, totpSetupTTL) {
@@ -150,7 +150,7 @@ func (s *Server) totpEnable(c *gin.Context) {
return
}
if !ok {
fail(c, http.StatusUnprocessableEntity, "invalid_code", "Code ungültig.")
fail(c, http.StatusUnprocessableEntity, "invalid_code")
return
}
sealedSecret := s.keys.Seal([]byte(secret), sess.UserID[:])
@@ -187,7 +187,7 @@ func (s *Server) totpDisable(c *gin.Context) {
}
for _, o := range me.Orgs {
if o.RequireTOTP {
fail(c, http.StatusConflict, "totp_required_by_org", "Eine deiner Organisationen verlangt TOTP.")
fail(c, http.StatusConflict, "totp_required_by_org")
return
}
}
@@ -202,7 +202,7 @@ func (s *Server) totpDisable(c *gin.Context) {
return
}
if user.PasswordHash == nil {
fail(c, http.StatusConflict, "no_password", "Konto ohne Passwort.")
fail(c, http.StatusConflict, "no_password")
return
}
if ok, _, err := auth.VerifyPassword(*user.PasswordHash, req.Password); err != nil || !ok {
@@ -213,7 +213,7 @@ func (s *Server) totpDisable(c *gin.Context) {
internalError(c, err)
return
} else if !ok {
fail(c, http.StatusUnauthorized, "invalid_code", "Code ungültig.")
fail(c, http.StatusUnauthorized, "invalid_code")
return
}
err = s.db.Tx(ctx, tenant.User(sess.UserID), func(q *store.Queries) error {