fix(cabana): translate hook ValidationError phrase keys in the request locale
- One shared localizer for ValidationError and ForbiddenError, tested in writeCRUDError's order; replaces the ForbiddenError-only one. - Applied on the CRUD and relation service transactions, the detached bulk branch, runAction, the record read (ShowRecord), and the reorder, singleton and relation-options routes, which localized neither type. - Only strings containing "::" are looked up, so translated text passes through unchanged and logs no missing-key warning. - Copy-on-write: the plugin's error value is never modified. - README and backend docs describe the localized ValidationError.
This commit is contained in:
@@ -103,7 +103,8 @@ func (s *service) singletonRoute(w http.ResponseWriter, r *http.Request) {
|
||||
if !errors.As(err, &missing) {
|
||||
slog.Error("cabana: singleton record failed", "controller", controllerID(cc), "error", err)
|
||||
}
|
||||
writeCRUDError(w, err)
|
||||
// A refusal from SingletonRecord carries plugin phrase keys.
|
||||
writeCRUDError(w, localizeControllerError(ctx, s.translator(), err))
|
||||
return
|
||||
}
|
||||
WriteData(w, http.StatusOK, result, nil)
|
||||
|
||||
Reference in New Issue
Block a user