webmozart / standalone-forms

139 stars 30 forks source link

Translation #13

Open loicdev opened 8 years ago

loicdev commented 8 years ago

Hey , First thanks for yout work to use Form Component alone. I have a problem when i try to translate the constraint messages in french. I just replace it like :

$translator = new Translator('fr');
        $translator->addLoader('xlf', new XliffFileLoader());
        $translator->addResource('xlf', VENDOR_FORM_DIR . '/Resources/translations/validators.fr.xlf', 'fr_FR', 'validators');
        $translator->addResource('xlf', VENDOR_VALIDATOR_DIR . '/Resources/translations/validators.fr.xlf', 'fr_FR', 'validators');
        $translator->setFallbackLocales(array('fr_FR'));

But it doest not work ..

loicdev commented 8 years ago

Finally i find the solution: insteant create validator like :

        $validator = Validation::createValidator();

I use this method

$builder = new ValidatorBuilder();
$validator = $builder
     ->setTranslator($translator)
     ->setTranslationDomain('validators')
     ->getValidator();
rechl commented 8 years ago

great! thank you!