I need to translate the error messages from my form type. Here is my form Type code:
class ReferFriendType extends AbstractType {
public function buildForm(Form
It`s easy, see http://symfony.com/doc/current/book/translation.html#translating-constraint-messages And set default_locale in /app/config/config.yml or play with $this->get('request')->setLocale('ru');
Validation translations go to the validators.LANG.yml
files — not messages.LANG.yml
ones.
There is an example in the docs.
The replacements are not set in the validation.yml file but by the Validator.
validators.en.yml
noFirstnameMinLimit: Please provide at least {{ limit }} characters
validation.yml
Acm\AddressBundle\Entity\Address:
properties:
firstname:
- Length:
min: 3
minMessage: "noFirstnameMinLimit"
This works for me with Symfony 2.4