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)

Merge branch '2.7'

* 2.7:
  [PhpUnitBridge] new bridge for testing with PHPUnit
  [FrameworkBundle] Check if templating is enabled.
  [Filesystem] Improve exception message for copy method
  [FrameworkBundle] Made ServerParams a service
  [2.7] [FrameworkBundle] bugfix in configuration for assets
  [FrameworkBundle] Enable assets by default.
  [Form] OptionsResolver 3.0 is not BC anymore
  [TwigBundle] add missing asset dependency
  Add an auto_alias compiler pass

Conflicts:
	.travis.yml
	composer.json
	src/Symfony/Bridge/Doctrine/composer.json
	src/Symfony/Bridge/Monolog/composer.json
	src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
	src/Symfony/Bridge/ProxyManager/composer.json
	src/Symfony/Bridge/Swiftmailer/composer.json
	src/Symfony/Bridge/Twig/composer.json
	src/Symfony/Bundle/DebugBundle/composer.json
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
	src/Symfony/Bundle/FrameworkBundle/composer.json
	src/Symfony/Bundle/SecurityBundle/composer.json
	src/Symfony/Bundle/TwigBundle/composer.json
	src/Symfony/Bundle/WebProfilerBundle/composer.json
	src/Symfony/Component/BrowserKit/composer.json
	src/Symfony/Component/ClassLoader/composer.json
	src/Symfony/Component/Console/composer.json
	src/Symfony/Component/Debug/composer.json
	src/Symfony/Component/DependencyInjection/composer.json
	src/Symfony/Component/DomCrawler/composer.json
	src/Symfony/Component/EventDispatcher/composer.json
	src/Symfony/Component/Form/composer.json
	src/Symfony/Component/HttpFoundation/composer.json
	src/Symfony/Component/HttpKernel/composer.json
	src/Symfony/Component/Intl/composer.json
	src/Symfony/Component/Routing/composer.json
	src/Symfony/Component/Security/Core/composer.json
	src/Symfony/Component/Security/Csrf/composer.json
	src/Symfony/Component/Security/Http/composer.json
	src/Symfony/Component/Security/composer.json
	src/Symfony/Component/Serializer/composer.json
	src/Symfony/Component/Translation/composer.json
	src/Symfony/Component/Validator/composer.json
Failed to load latest commit information.
Catalogue Merge branch '2.5'
Dumper [3.0] Removed some old hacks
Exception [Translation] uniformized the way exception are thrown in LoaderInter…
Extractor made {@inheritdoc} annotations consistent across the board
Loader Merge branch '2.5' into 2.6
Tests Merge branch '2.7'
Writer Merge branch '2.3' into 2.5
.gitignore Added missing files .gitignore
CHANGELOG.md [Translation][changelog] fix typo.
IdentityTranslator.php [Translation] make IdentityTranslater consistent with normal translator
Interval.php Docblock fixes
LICENSE Updated copyright to 2015
LoggingTranslator.php [Translator][Logging] implement TranslatorBagInterface.
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 Refresh catalogues when resources change
TranslatorBagInterface.php [Translation] added LoggingTranslator.
TranslatorInterface.php Merge branch '2.3' into 2.4
composer.json Merge branch '2.7'
phpunit.xml.dist [PhpUnitBridge] new bridge for testing with PHPUnit

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.