036c946172
* 2.8: (100 commits) [DependencyInjection] provide better error message when using deprecated configuration options [console][TableCell] get cell width without decoration. Improve the config validation in TwigBundle [VarDumper] Changed tooltip to expand-all keybinding in OS X [Bridge\PhpUnit] Fix composer installed phpunit detection [VarDumper] Fix generic casters calling order [2.7][SecurityBundle] Remove SecurityContext from Compile [WebProfilerBundle][logger] added missing deprecation message. Fix profiler CSS [Security][Acl] enforce string identifiers [FrameworkBundle] make `templating.helper.router` service available again for BC reasons [BrowserKit] Fix bug when uri starts with http. bumped Symfony version to 2.7.1 updated VERSION for 2.7.0 updated CHANGELOG for 2.7.0 bumped Symfony version to 2.6.10 updated VERSION for 2.6.9 updated CHANGELOG for 2.6.9 fixed tests bumped Symfony version to 2.3.31 ... Conflicts: CHANGELOG-2.3.md CHANGELOG-2.6.md CHANGELOG-2.7.md UPGRADE-2.7.md UPGRADE-3.0.md src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php src/Symfony/Bridge/Twig/Extension/AssetExtension.php src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php src/Symfony/Bundle/FrameworkBundle/composer.json src/Symfony/Bundle/SecurityBundle/composer.json src/Symfony/Component/Debug/ExceptionHandler.php src/Symfony/Component/DependencyInjection/Container.php src/Symfony/Component/DependencyInjection/Definition.php src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/legacy-services6.xml src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/legacy-services6.yml src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php src/Symfony/Component/Form/CHANGELOG.md src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php src/Symfony/Component/Routing/Loader/XmlFileLoader.php src/Symfony/Component/Routing/Loader/YamlFileLoader.php |
||
---|---|---|
.. | ||
Catalogue | ||
DataCollector | ||
Dumper | ||
Exception | ||
Extractor | ||
Loader | ||
Tests | ||
Util | ||
Writer | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
DataCollectorTranslator.php | ||
IdentityTranslator.php | ||
Interval.php | ||
LICENSE | ||
LoggingTranslator.php | ||
MessageCatalogue.php | ||
MessageCatalogueInterface.php | ||
MessageSelector.php | ||
MetadataAwareInterface.php | ||
phpunit.xml.dist | ||
PluralizationRules.php | ||
README.md | ||
Translator.php | ||
TranslatorBagInterface.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:
https://symfony.com/doc/3.0/book/translation.html
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Translation/
$ composer install
$ phpunit