This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Translation
2015-03-27 23:05:05 +01:00
..
Catalogue Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
Dumper Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
Exception [Translation] uniformized the way exception are thrown in LoaderInterface::load() 2012-12-13 11:00:37 +01:00
Extractor made {@inheritdoc} annotations consistent across the board 2014-04-16 09:04:20 +02:00
Loader CS: Binary operators should be arounded by at least one space 2015-03-27 23:05:05 +01:00
Tests Fix small coding style 2015-03-21 18:53:24 +01:00
Writer [FrameworkBundle] Fixed Translation loader and update translation command. 2014-12-21 12:33:47 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md updated various CHANGELOG files that were not updated when the PRs were merged 2013-03-23 08:35:36 +01:00
composer.json [2.3] require-dev PHPUnit bridge 2015-02-24 11:24:26 +01:00
IdentityTranslator.php [Validation] Fixed IdentityTranslator to pass correct Locale to MessageSelector 2013-08-19 12:15:39 +02:00
Interval.php Docblock fixes 2014-11-30 13:33:44 +00:00
LICENSE Updated copyright to 2015 2015-01-01 13:56:52 +01:00
MessageCatalogue.php unified return null usages 2014-04-16 09:43:51 +02:00
MessageCatalogueInterface.php Docblock fixes 2014-11-30 13:33:44 +00:00
MessageSelector.php Docblock fixes 2014-11-30 13:33:44 +00:00
MetadataAwareInterface.php Fix doc blocks 2014-04-18 22:17:16 +02:00
phpunit.xml.dist [2.3] require-dev PHPUnit bridge 2015-02-24 11:24:26 +01:00
PluralizationRules.php CS: Convert double quotes to single quotes 2015-03-21 12:11:30 +01:00
README.md renamed composer.phar to composer to be consistent with the Symfony docs 2015-02-08 08:41:14 +01:00
Translator.php Add tests and more assertions 2014-09-02 09:12:49 +02:00
TranslatorInterface.php Docblock fixes 2014-11-30 13:33:44 +00: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:

http://symfony.com/doc/2.3/book/translation.html

You can run the unit tests with the following command:

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