]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | Translation Component |
2 | ===================== | |
3 | ||
4 | Translation provides tools for loading translation files and generating | |
5 | translated strings from these including support for pluralization. | |
6 | ||
7 | use Symfony\Component\Translation\Translator; | |
8 | use Symfony\Component\Translation\MessageSelector; | |
9 | use Symfony\Component\Translation\Loader\ArrayLoader; | |
10 | ||
11 | $translator = new Translator('fr_FR', new MessageSelector()); | |
12 | $translator->setFallbackLocales(array('fr')); | |
13 | $translator->addLoader('array', new ArrayLoader()); | |
14 | $translator->addResource('array', array( | |
15 | 'Hello World!' => 'Bonjour', | |
16 | ), 'fr'); | |
17 | ||
18 | echo $translator->trans('Hello World!')."\n"; | |
19 | ||
20 | Resources | |
21 | --------- | |
22 | ||
23 | Silex integration: | |
24 | ||
25 | https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php | |
26 | ||
27 | Documentation: | |
28 | ||
29 | http://symfony.com/doc/2.3/book/translation.html | |
30 | ||
31 | You can run the unit tests with the following command: | |
32 | ||
33 | $ cd path/to/Symfony/Component/Translation/ | |
34 | $ composer.phar install --dev | |
35 | $ phpunit |