I have been using respect validation 1.1 and I used below code for translating messages.
foreach ($rules as $field => $rule) {
try {
$localeField = $translator->trans($field);
$rule->setName($localeField)->assert($request->getParam($field));
} catch (NestedValidationException $e) {
$translateMessage = function($message) use ($translator){
return $translator->trans($message);
};
$e->setParam('translator', $translateMessage);
$this->errors[$field] = $e->getMessages();
}
Now I'm using respect validation version 2.2 and in this version there is no setParam function for error object. So I'm wondering how I'm able to translate messages in this version. Please help! thanks in advance.
Translation of messages is a bit different in the new version, since you have to use a factory to declare how the default instance is built.
I include here an example that I found in the
Respect/Validationintegration tests:What you will see here as output is the
0 deve ser do tipo stringstring.