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:
@@ -868,9 +868,10 @@ func relationSelects(db *gorm.DB, cr *CompiledRelation, target any, cols []Relat
|
||||
}
|
||||
|
||||
// transaction runs fn in lagoon.Transaction on the service's database and
|
||||
// localizes a *ForbiddenError a relation hook returned (D-27).
|
||||
// localizes a *ValidationError or *ForbiddenError (D-27) a relation hook
|
||||
// returned.
|
||||
func (s RelationService) transaction(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error) error {
|
||||
return localizeForbidden(ctx, s.tr, lagoon.Transaction(ctx, s.DB, fn))
|
||||
return localizeControllerError(ctx, s.tr, lagoon.Transaction(ctx, s.DB, fn))
|
||||
}
|
||||
|
||||
// Link links eligible related records to the parent and never restamps
|
||||
|
||||
Reference in New Issue
Block a user