7c05b59708
gates / gates (push) Successful in 24s
179 Hungarian sentences were built deep inside a package with fmt.Errorf and printed by whoever caught them: too late to translate where they are shown, too early where they are made. Every one now carries its key across that gap. ZERO Hungarian error literals remain. util.MsgError does three things at once, each earned: - Error() is the Hungarian, byte for byte, so every un-converted printer is unchanged; - errors.Is answers for the kind AND for a wrapped cause (KindErrorf dropped the cause); - an error ARGUMENT renders recursively, so "formázás sikertelen: %w" translates whole. A foreign error — restic, docker, ssh, the stdlib — prints verbatim. It is not ours. 76 display sites go through errText, and TestNoErrErrorInPageOutput convicts any that do not. memoryVerdict returns an error rather than a sentence, so the deploy's 409 and the household's language come from one value; UpdateRefusal gained a Cause to carry it. Plurals, one rule, stated once: a key with .one/.other takes its COUNT first. Not a per-call-site flag — the producer somebody forgot would read "3 app is not running". The guard caught a real key collision (alert.deadapp.one) the day the rule landed. TWO DEFECTS FOUND IN MY OWN TOOLING, recorded rather than quietly fixed. The bulk converter silently dropped multi-line concatenations, damaging 7 producers — and the parity gate could not see it, because every surviving fragment WAS a real base literal while the CALL had lost text; two behaviour tests caught it. And the counting script was case-sensitive, so it said "0 left" while five remained. MinAgent: 0.131.0 (unchanged). No hub release needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
45 lines
2.0 KiB
Go
45 lines
2.0 KiB
Go
package stacks
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/i18n"
|
|
)
|
|
|
|
// R-553 — the deploy path's refusals carry a KIND, so the API can pick its status code without
|
|
// reading the customer's Hungarian sentence. The sentences themselves are unchanged (a test pins
|
|
// each one byte-for-byte); `internal/util.KindErrorf` builds the message exactly as fmt.Errorf did.
|
|
//
|
|
// Before this, internal/api/router.go matched „kötelező", „memória", "does not exist" and
|
|
// "already deployed" in the error text — so localisation slice 2 would have turned every validation
|
|
// refusal into a 500.
|
|
var (
|
|
// ErrAlreadyDeployed — the stack is already deployed (API: 409).
|
|
ErrAlreadyDeployed = errors.New("stack already deployed")
|
|
// ErrRequiredField — a required (or password) field was left empty (API: 400).
|
|
ErrRequiredField = errors.New("required field empty")
|
|
// ErrPathMissing — a path field names something that is not on the filesystem (API: 400).
|
|
ErrPathMissing = errors.New("path field does not exist")
|
|
// ErrNotEnoughMemory — the memory verdict refused the deploy (API: 400).
|
|
ErrNotEnoughMemory = errors.New("not enough memory")
|
|
)
|
|
|
|
// msgHU renders a bundle message in Hungarian.
|
|
//
|
|
// It exists for the few strings this package returns as TEXT rather than as an error — the soft
|
|
// overcommit warning is the only one today. Those are display strings with no error to carry a key,
|
|
// so the copy lives in the bundle (a translator sees it, and scripts/i18n_go_parity.py pins it) while
|
|
// the value handed back is still Hungarian. **The consequence, stated rather than hidden: such a
|
|
// string renders Hungarian on an English page.** Filed as R-575; the fix is for the caller to carry
|
|
// the key the way Alert and UpdateRefusal do, not for this helper to guess a language it cannot know.
|
|
func msgHU(key string, args ...interface{}) string {
|
|
b, err := i18n.Shared()
|
|
if err != nil {
|
|
return key
|
|
}
|
|
if len(args) == 0 {
|
|
return b.Msg(i18n.Default, key)
|
|
}
|
|
return b.Msgf(i18n.Default, key, args...)
|
|
}
|