Last Updated: February 25, 2016
·
1.248K
· dsalvagni

Translating your validation messages errors in ZF2

This is a pretty nice tip that helps you to use the ZF2 languages files to translate the validation messages in the form.

With your translations settings previously added, you need to use a ZF2 Form View Helper - http://goo.gl/r2JDBB - in the form view to define wich language to use, based on your text_domain.

$this->formElementErrors()->setTranslatorTextDomain(__NAMESPACE__);

Now you can change your validation messages on your language files on the folder:

/vendor/zendframework/zendframework/resources/languages