Files
llmgw/internal/web/errors_i18n.go
T
Ilker ManapandClaude Opus 5.5 f8d18efaef Turkish pages are Turkish to the end
The errors other packages give a page (store, catalog, mirror) are
shown in its language; a percentage is written as the language writes
it (%93 in Turkish); the footer's time in its date form; and a stale
form is refused with a sentence rather than "bad request".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-21 09:22:42 +02:00

45 lines
1.7 KiB
Go

package web
import (
"net/http"
"gitea.mynodes.xyz/ilker/llmgw/internal/account"
"gitea.mynodes.xyz/ilker/llmgw/internal/control/catalog"
"gitea.mynodes.xyz/ilker/llmgw/internal/mirror"
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
)
// The errors of other packages a page can show, in the page's language: an
// administrator's page in Turkish said "not found" and "not empty" in
// English, because they came from the store as written there.
func init() {
for err, key := range map[error]string{
store.ErrNotFound: "err.not_found",
store.ErrNotEmpty: "err.not_empty",
store.ErrDuplicateName: "err.duplicate_name",
store.ErrEmailTaken: "err.email_taken",
store.ErrKeyTTL: "err.key_ttl",
store.ErrNotMember: "err.not_member",
store.ErrOwnerInactive: "err.owner_inactive",
store.ErrSettingsChanged: "err.settings_changed",
store.ErrNoSession: "err.no_session",
store.ErrKnowledgeOff: "err.knowledge_off",
store.ErrMemoryNotEnabled: "err.memory_off",
store.ErrMemoryFull: "err.memory_full",
store.ErrThreadsNotEnabled: "err.threads_off",
account.ErrNoReset: "err.no_reset",
catalog.ErrExists: "err.in_catalog",
mirror.ErrAlreadyFetching: "err.mirror_fetching",
mirror.ErrExists: "err.mirror_exists",
mirror.ErrIncomplete: "err.mirror_incomplete",
} {
registerErrorKey(err, key)
}
}
// badForm answers a form whose token did not match: one left open too long,
// or sent from another site. In the page's language, plainly.
func badForm(w http.ResponseWriter, r *http.Request) {
http.Error(w, langOf(r).T("err.bad_form"), http.StatusBadRequest)
}