Skip to content
[READ-ONLY] Subtree split of the Symfony Translation Component
Latest commit 74893d6 @nicolas-grekas nicolas-grekas Merge branch '3.0'
* 3.0: (105 commits)
  [Console] remove readline support
  bumped Symfony version to 3.0.3
  updated VERSION for 3.0.2
  updated CHANGELOG for 3.0.2
  [Routing] added a suggestion to add the HttpFoundation component.
  [FrameworkBundle] fix assets and templating tests
  [ClassLoader] fix ApcClassLoader tests on HHVM
  [travis] Add some comments
  changed operator from and to &&
  [DependencyInjection] Remove unused parameter
  [Process] Fix transient tests for incremental outputs
  [Console] Add missing `@require` annotation in test
  Fix merge
  [appveyor] Fix failure reporting
  [#17634] move DebugBundle license file
  Limit Ldap component version for the 3.0 branch
  backport GlobTest from 2.7 branch
  Move licenses according to new best practices
  [FrameworkBundle] Remove unused code in test
  [2.3] Fixed an undefined variable in Glob::toRegex

Failed to load latest commit information.
Catalogue Merge branch '2.8' into 3.0
DataCollector Rely on iconv and symfony/polyfill-*
Dumper Merge branch '2.8' into 3.0
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' into 3.0
Util [Translation] add options 'as_tree', 'inline' to YamlFileDumper to du…
Writer bug #16912 [Translation][Writer] avoid calling setBackup if the dumpe…
.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 Update copyright year
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' updated version to 3.1
Translator.php Merge branch '2.8' into 3.0
TranslatorBagInterface.php [2.6][Translation] remove duplicate code for loading catalogue.
TranslatorInterface.php Merge branch '2.3' into 2.7
composer.json updated version to 3.1
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.