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
Fabien Potencier d31bf634da Merge branch '2.5'
* 2.5: (23 commits)
  [HttpKernel] fixed some unit tests for 2.4 (signature now uses SHA256 instead of MD5)
  [HttpKernel] simplified code
  [HttpKernel] fixed internal fragment handling
  fixing yaml indentation
  Unexpexted ));"
  [WebProfiler] replaced the import/export feature from the web interface to a CLI tool
  Forced all fragment uris to be signed, even for ESI
  Add tests and more assertions
  [FrameworkBundle][Translator] Validate locales.
  [HttpFoundation] added some missing tests
  [HttpFoundation] Improve string values in test codes
  [Security] Add more tests for StringUtils::equals
  fix comment: not fourth but sixth argument
  fixing typo in a comment
  [FrameworkBundle] fixed CS
  [FrameworkBundle] PhpExtractor bugfix and improvements
  [Finder] Fix findertest readability
  [Filesystem] Add FTP stream wrapper context option to enable overwrite (override)
  fix parsing of Authorization header
  Test examples from Drupal SA-CORE-2014-003
  ...

Conflicts:
	src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig
	src/Symfony/Component/Filesystem/Filesystem.php
	src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php
2014-09-03 11:12:11 +02:00
..
Catalogue [Translation] [Xliff] Support for <note> 2014-06-17 07:29:56 +02:00
Dumper feature #11371 [Translation:update][Xliff Dumper] added target-language. (aitboudad, ClementGautier) 2014-07-11 13:07:55 +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 Merge branch '2.5' 2014-07-28 15:20:53 +02:00
Tests feature #9859 [Translation] added method to expose collected message (Grygir) 2014-08-27 14:55:31 +02:00
Writer Fix issue 9172 2014-05-04 18:56:58 +02:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Translation] added method to expose collected messages 2014-08-18 16:11:02 +03:00
composer.json updated version to 2.6 2014-05-23 16:36:49 +02:00
IdentityTranslator.php [Translation] make IdentityTranslater consistent with normal translator 2013-11-20 03:31:35 +01:00
Interval.php fixed types in phpdocs 2014-04-16 12:30:19 +02:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
MessageCatalogue.php unified return null usages 2014-04-16 09:43:51 +02:00
MessageCatalogueInterface.php fixed types in phpdocs 2014-04-16 12:30:19 +02:00
MessageSelector.php Update MessageSelector.php to show which value was passed 2014-05-14 09:24:58 -04:00
MetadataAwareInterface.php Fix doc blocks 2014-04-18 22:17:16 +02:00
phpunit.xml.dist removed defaults from PHPUnit configuration 2014-07-07 12:13:42 +02:00
PluralizationRules.php Merge branch '2.4' 2014-04-18 23:02:40 +02:00
README.md updated version to 2.6 2014-05-23 16:36:49 +02:00
Translator.php Merge branch '2.5' 2014-09-03 11:12:11 +02:00
TranslatorInterface.php Merge branch '2.3' into 2.4 2014-07-15 16:07:10 +02: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.6/book/translation.html

You can run the unit tests with the following command:

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