Skip to content

Commit

Permalink
tweaked documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 16, 2012
1 parent 38d505a commit 2ebc476
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions doc/providers/translation.rst
Expand Up @@ -128,20 +128,18 @@ use is ``locales/en.yml``. Just do the mapping in this file as follows:
hello: Hello %name%
goodbye: Goodbye %name%
Repeat this for all of your languages. Then add the files to the
``translator``::

$app['translator']->addResource('yaml', __DIR__.'/locales/en.yml', 'en');
$app['translator']->addResource('yaml', __DIR__.'/locales/de.yml', 'de');
$app['translator']->addResource('yaml', __DIR__.'/locales/fr.yml', 'fr');

Finally, register the ``YamlFileLoader`` on the translator::
Then, register the ``YamlFileLoader`` on the ``translator`` and add all your
translation files::

use Symfony\Component\Translation\Loader\YamlFileLoader;

$app['translator'] = $app->share($app->extend('translator', function($translator, $app) {
$translator->addLoader('yaml', return new YamlFileLoader());

$translator->addResource('yaml', __DIR__.'/locales/en.yml', 'en');
$translator->addResource('yaml', __DIR__.'/locales/de.yml', 'de');
$translator->addResource('yaml', __DIR__.'/locales/fr.yml', 'fr');

return $translator;
}));

Expand All @@ -154,9 +152,9 @@ Symfony2 ``Config`` component as a dependency (see above for details).
Then, similarly, create XLIFF files in your locales directory and add them to
the translator::

$app['translator']->addResource('xliff', __DIR__.'/locales/en.xlf', 'en');
$app['translator']->addResource('xliff', __DIR__.'/locales/de.xlf', 'de');
$app['translator']->addResource('xliff', __DIR__.'/locales/fr.xlf', 'fr');
$translator->addResource('xliff', __DIR__.'/locales/en.xlf', 'en');
$translator->addResource('xliff', __DIR__.'/locales/de.xlf', 'de');
$translator->addResource('xliff', __DIR__.'/locales/fr.xlf', 'fr');

.. note::

Expand Down

0 comments on commit 2ebc476

Please sign in to comment.