I have SF2.3 at my webserver. I am using validatorBuilder to validate my data.
Here is my config:
framework:
translator: { fallback: ru }
default_locale: ru
Here is my event listener:
// EventListener.php
...
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->getValidator();
But when I get error messages they are in english, not in 'ru' locale. What am I doing wrong?
Here is the solution:
$trans = new Translator('ru');
$trans->addLoader('xliff', new XliffFileLoader());
$trans->addResource('xliff', __DIR__.'/../Resources/translations/validators.ru.xlf', 'ru', 'validators');
$this->validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->setTranslator($trans)
->setTranslationDomain('validators')
->getValidator();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.