website/vendor/symfony/translation
2015-08-30 12:33:20 -04:00
..
Catalogue Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
DataCollector Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Dumper Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Exception Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Extractor Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Loader Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Tests Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Writer Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
CHANGELOG.md Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
composer.json Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
DataCollectorTranslator.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
IdentityTranslator.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Interval.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
LICENSE Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
LoggingTranslator.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
MessageCatalogue.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
MessageCatalogueInterface.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
MessageSelector.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
MetadataAwareInterface.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
phpunit.xml.dist Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
PluralizationRules.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
README.md Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
Translator.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
TranslatorBagInterface.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00
TranslatorInterface.php Added vendor/ directory for Composer's installed files 2015-08-30 12:33:20 -04:00

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:

https://symfony.com/doc/2.7/book/translation.html

You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/Translation/
$ composer install
$ phpunit