Commit d7df7eb8 authored by Sasa Stamenkovic's avatar Sasa Stamenkovic

Added Translating Validation Messages to cookbook.

parent c38e96db
Translating Validation Messages
===============================
When working with Symfony2 forms, a common task would be to show localized validation messages.
In order to do that, you will need to register translator and point to translated resources:
::
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale' => 'sr_Latn',
'translation.class_path' => __DIR__ . '/vendor/symfony/src',
'translator.messages' => array()
));
$app['translator']->addLoader('xlf', new Symfony\Component\Translation\Loader\XliffFileLoader());
$app['translator']->addResource('xlf', __DIR__ . '/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.sr_Latn.xlf', 'sr_Latn', 'validators');
And that's all you need to load translations from Symfony2 ``xlf`` files.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment