Skip to content


Subversion checkout URL

You can clone with
Download ZIP
[READ-ONLY] Subtree split of the Symfony Translation Component -- clone into Symfony/Component/ (master at symfony/symfony)

Merge branch '2.8'

* 2.8:
  [Console] ProgressBarTest::testAnsiColorsAndEmojis() requires extension mbstring
  [SecurityBundle] Skip SetAclCommandTest when sqlite is not available
  [VarDumper] Windows compat for SplCasterTest
  [Translation][Xliff loader] fixed check target node.
Failed to load latest commit information.
Catalogue Merge branch '2.5'
DataCollector Merge branch '2.7' into 2.8
Dumper Add support for target attributes.
Exception [Translation] uniformized the way exception are thrown in LoaderInter…
Extractor [Translation][Extractor] Allow extracting an array of files besides e…
Loader [Translation][Xliff loader] fixed check target node.
Tests Merge branch '2.8'
Util [Translation] add options 'as_tree', 'inline' to YamlFileDumper to du…
Writer Merge branch '2.3' into 2.5
.gitignore Added missing files .gitignore [Translator] changed the visibility of the locale from protected to p…
DataCollectorTranslator.php [Translation] Add parameters to DataCollectorTranslator
IdentityTranslator.php [Translation] make IdentityTranslater consistent with normal translator
Interval.php Docblock fixes
LICENSE Updated copyright to 2015
LoggingTranslator.php [2.6][Translation] remove duplicate code for loading catalogue.
MessageCatalogue.php unified return null usages
MessageCatalogueInterface.php Docblock fixes
MessageSelector.php Merge branch '2.3' into 2.6
MetadataAwareInterface.php Fix doc blocks
PluralizationRules.php Merge branch '2.3' into 2.6 Merge branch '2.8'
Translator.php Merge branch '2.8'
TranslatorBagInterface.php [2.6][Translation] remove duplicate code for loading catalogue.
TranslatorInterface.php Merge branch '2.3' into 2.4
composer.json Merge branch '2.8'
phpunit.xml.dist [2.3] require-dev PHPUnit bridge

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->addLoader('array', new ArrayLoader());
$translator->addResource('array', array(
    'Hello World!' => 'Bonjour',
), 'fr');

echo $translator->trans('Hello World!')."\n";


Silex integration:


You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/Translation/
$ composer install
$ phpunit
Something went wrong with that request. Please try again.