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
2014-01-07 08:19:25 -05:00
..
Catalogue Enforce sprintf for exceptions 2013-04-11 08:50:46 +02:00
Dumper fixed various typos 2013-12-27 16:08:19 +01:00
Exception [Translation] uniformized the way exception are thrown in LoaderInterface::load() 2012-12-13 11:00:37 +01:00
Extractor CS Fixes - Replaced "array of type" by "Type[]" in PHPDoc block 2012-11-19 13:58:52 +01:00
Loader Fix Empty translations with Qt files 2014-01-07 09:33:09 +01:00
Tests fixes PSR-0 issues in tests 2013-12-30 22:13:42 +01:00
Writer Fixed most of the docblocks/unused namespaces 2012-12-19 08:09:49 +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 removed versions in composer.json files 2013-05-13 16:36:40 +02:00
IdentityTranslator.php [Validation] Fixed IdentityTranslator to pass correct Locale to MessageSelector 2013-08-19 12:15:39 +02:00
Interval.php Fixed most of the docblocks/unused namespaces 2012-12-19 08:09:49 +01:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
MessageCatalogue.php [Translator] fix metadata 2013-02-14 10:33:29 +01:00
MessageCatalogueInterface.php [Translator] fix phpdoc of MessageCatalogueInterface::add and ::replace 2013-02-14 09:39:14 +01:00
MessageSelector.php [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used 2013-08-23 17:24:14 +02:00
MetadataAwareInterface.php [Translator] fix metadata 2013-02-14 10:33:29 +01:00
phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
PluralizationRules.php [Translation] Removed an unneeded return annotation. 2013-09-13 13:15:01 +01:00
README.md Merge branch '2.2' into 2.3 2013-09-19 11:45:20 +02:00
Translator.php Merge branch '2.2' 2013-05-10 20:12:13 +02:00
TranslatorInterface.php [Translator] mention that the message id may also be an object that can be cast to string in TranslatorInterface and fix the IdentityTranslator that did not respect this 2013-02-14 09:35:42 +01: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.phar install
$ phpunit