d31bf634da
* 2.5: (23 commits) [HttpKernel] fixed some unit tests for 2.4 (signature now uses SHA256 instead of MD5) [HttpKernel] simplified code [HttpKernel] fixed internal fragment handling fixing yaml indentation Unexpexted ));" [WebProfiler] replaced the import/export feature from the web interface to a CLI tool Forced all fragment uris to be signed, even for ESI Add tests and more assertions [FrameworkBundle][Translator] Validate locales. [HttpFoundation] added some missing tests [HttpFoundation] Improve string values in test codes [Security] Add more tests for StringUtils::equals fix comment: not fourth but sixth argument fixing typo in a comment [FrameworkBundle] fixed CS [FrameworkBundle] PhpExtractor bugfix and improvements [Finder] Fix findertest readability [Filesystem] Add FTP stream wrapper context option to enable overwrite (override) fix parsing of Authorization header Test examples from Drupal SA-CORE-2014-003 ... Conflicts: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig src/Symfony/Component/Filesystem/Filesystem.php src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php |
||
---|---|---|
.. | ||
Catalogue | ||
Dumper | ||
Exception | ||
Extractor | ||
Loader | ||
Tests | ||
Writer | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
IdentityTranslator.php | ||
Interval.php | ||
LICENSE | ||
MessageCatalogue.php | ||
MessageCatalogueInterface.php | ||
MessageSelector.php | ||
MetadataAwareInterface.php | ||
phpunit.xml.dist | ||
PluralizationRules.php | ||
README.md | ||
Translator.php | ||
TranslatorInterface.php |
Translation Component
Translation provides tools for loading translation files and generating translated strings from these including support for pluralization.
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\ArrayLoader;
$translator = new Translator('fr_FR', new MessageSelector());
$translator->setFallbackLocales(array('fr'));
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', array(
'Hello World!' => 'Bonjour',
), 'fr');
echo $translator->trans('Hello World!')."\n";
Resources
Silex integration:
https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php
Documentation:
http://symfony.com/doc/2.6/book/translation.html
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Translation/
$ composer.phar install
$ phpunit