Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

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

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Catalogue Merge branch '2.5'
DataCollector [Translation][Profiler] reduce memory usage for collected messages.
Exception [Translation] uniformized the way exception are thrown in LoaderInter…
Extractor [Translation][Extractor] Allow extracting an array of files besides e…
Loader [Translation] added FileLoader.
Tests Merge branch '2.8'
Writer Merge branch '2.3' into 2.5
.gitignore Added missing files .gitignore [2.7][Translation][change log] added DataCollectorTranslator.
DataCollectorTranslator.php [2.7][Translation] remove duplicate code for loading catalogue.
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.5
MetadataAwareInterface.php Fix doc blocks
PluralizationRules.php Merge branch '2.3' into 2.5 Merge branch '2.7'
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.