Skip to content

HTTPS clone URL

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)
PHP

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.
Dumper
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
CHANGELOG.md [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
README.md 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

README.md

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/3.0/book/translation.html

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.