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)
Latest commit 7f14717 @nicolas-grekas nicolas-grekas Merge branch '2.8'
* 2.8:
  Fix undefined array $server
  Fix call to undefined function json_last_error_message
  Fix bug in windows detection
  [ProxyManager] Tmp fix composer reqs issue in ZF
  Fix PropertyInfo extractor namespace in framework bundle
  Add missing exclusions from phpunit.xml.dist
  [Serializer] ObjectNormalizer: don't serialize static methods and props
  [Form] Enhance some FormRegistry deprecation messages
  [Validator] [sl] BIC (SWIFT-BIC) validation constraint
  [WebProfilerBundle] correct typo in show stack trace link
  bumped Symfony version to 2.8.0
  updated VERSION for 2.8.0-BETA1
  updated CHANGELOG for 2.8.0-BETA1
  Fix the server variables in the router_*.php files
  [Validator] Allow an empty path with a non empty fragment or a query
  The following change adds support for Armenian pluralization.
  [2.3][Process] fix Proccess run with pts enabled

Failed to load latest commit information.
Catalogue [Translator] remove deprecated DiffOperation class.
DataCollector Rely on iconv and symfony/polyfill-*
Dumper [Translation][file dump] remove deprecated format method.
Exception remove api tags from code
Extractor [Translation][Extractor] Allow extracting an array of files besides e…
Loader Rely on iconv and symfony/polyfill-*
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 [Translation][file dump] remove deprecated format method.
DataCollectorTranslator.php Merge branch '2.7' into 2.8
IdentityTranslator.php Merge branch '2.3' into 2.7
Interval.php Docblock fixes
LICENSE Updated copyright to 2015
LoggingTranslator.php remove api tags that are new in 2.7
MessageCatalogue.php remove api tags from code
MessageCatalogueInterface.php remove api tags from code
MessageSelector.php Merge branch '2.3' into 2.7
MetadataAwareInterface.php Fix doc blocks
PluralizationRules.php Merge branch '2.8' 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.7
composer.json Merge branch '2.8'
phpunit.xml.dist Add missing exclusions from phpunit.xml.dist

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.