Respect/Validation won't do the translation for you, you should use a different project, library or function to do that. It won't leave you empty handed though, as the documentation states.
First, you should try to understand how translation libraries work (such as gettext()
) and then read PHP documentation on Callables. Then it is a matter of choosing a library, creating the translations and calling setParam('translator', 'callable')
method on the exception instance.
A quick introduction to your problem:
- Translations are done based on a
source
: it can be a file
, a database
or something else, depending on which library you use.
- Respect/Validation exception messages use the same pattern:
{{name}} is invalid.
. Where {{name}}
will be replaced by the input
given or the name
if setName()
was called on that rule.
- You can see all messages you need to translate under the
Respect\Validation\Exceptions
namespace.
- Usually, every library provide a single function/method to translate a given string. This is the method/function you want to set on the
$exception->setParam()
call.
If you ever translate all exception messages, we would love to make them available to everyone else.
PS: You could also make this question on the repository page, more people would help and we could also improve the way translations are handled by the library in the future.