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-09-03 22:55:07 +02:00
..
Catalogue Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
Dumper improved exception when missing required component 2015-04-22 17:09:08 +02: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 [Translation] Fix the string casting in the XliffFileLoader 2015-08-26 11:54:34 +02:00
Tests [Translator][fallback catalogues] fixed circular reference. 2015-09-02 09:56:25 +00: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 link to https://symfony.com where possible 2015-05-01 16:06:45 +02: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 [Translator][fallback catalogues] fixed circular reference. 2015-09-02 09:56:25 +00:00
MessageCatalogueInterface.php Docblock fixes 2014-11-30 13:33:44 +00:00
MessageSelector.php Allow new lines in Messages translated with transchoice() (replacement for #14867) 2015-06-11 15:52:49 +02: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 Azerbaijani language pluralization rule 2015-07-01 16:29:20 +02:00
README.md use new repo location in some readme.md 2015-09-03 22:55:07 +02:00
Translator.php [Translator][fallback catalogues] fixed circular reference. 2015-09-02 09:56:25 +00: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/silexphp/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php

Documentation:

https://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