feff411dfc
* 2.3: Clear lazy loading initializer after the service is successfully initialized [FrameworkBundle] added support for double-quoted strings in the extractor (closes #8797) [SecurityBundle] Move format-dependent tests from SecurityExtensionTest bumped Symfony version to 2.3.5-DEV updated VERSION for 2.3.4 updated CHANGELOG for 2.3.4 bumped Symfony version to 2.2.7 updated VERSION for 2.2.6 update CONTRIBUTORS for 2.2.6 updated CHANGELOG for 2.2.6 clearToken exception is thrown at wrong place. fix typo in test skipped message [Form] Fixed Form::all() signature for PHP 5.3.3 [Form] Fixed Form::all() signature for PHP 5.3.3 [Locale] Fixed: Locale::setDefault() throws no exception when "en" is passed [Locale] Fixed: StubLocale::setDefault() throws no exception when "en" is passed [Translation] Grammar fix [Yaml] fixed embedded folded string parsing [Validator] fixed Boolean handling in XML constraint mappings (closes #5603) [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used Conflicts: src/Symfony/Component/HttpKernel/Kernel.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.4/book/translation.html
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Translation/
$ composer.phar install --dev
$ phpunit