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 a6bc12c9c1 Merge branch '2.0'
* 2.0:
  updated VERSION for 2.0.17
  updated CHANGELOG for 2.0.17
  updated vendors for 2.0.17
  fixed XML decoding attack vector through external entities
  prevents injection of malicious doc types
  disabled network access when loading XML documents
  refined previous commit
  prevents injection of malicious doc types
  standardized the way we handle XML errors
  Redirects are now absolute

Conflicts:
	CHANGELOG-2.0.md
	src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
	src/Symfony/Component/DomCrawler/Crawler.php
	src/Symfony/Component/HttpKernel/Kernel.php
	tests/Symfony/Tests/Component/DependencyInjection/Loader/XmlFileLoaderTest.php
	tests/Symfony/Tests/Component/Routing/Loader/XmlFileLoaderTest.php
	tests/Symfony/Tests/Component/Serializer/Encoder/XmlEncoderTest.php
	tests/Symfony/Tests/Component/Translation/Loader/XliffFileLoaderTest.php
	tests/Symfony/Tests/Component/Validator/Mapping/Loader/XmlFileLoaderTest.php
	vendors.php
2012-08-28 09:54:42 +02:00
..
Dumper fixed CS 2012-07-09 14:54:20 +02:00
Extractor fixed CS 2012-07-09 14:54:20 +02:00
Loader Merge branch '2.0' 2012-08-28 09:54:42 +02:00
Tests Merge branch '2.0' 2012-08-28 09:54:42 +02:00
Writer add format to exception message 2012-08-14 16:38:05 +02:00
.gitignore [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
CHANGELOG.md [Translation] added CHANGELOG 2012-04-26 19:56:13 +02:00
composer.json Add minimum-stability (dev) in each component 2012-08-22 15:48:41 +02:00
IdentityTranslator.php [Translation] tagged the guaranteed BC API 2011-03-24 09:07:52 +01:00
Interval.php fixed CS 2012-07-09 14:54:20 +02:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
MessageCatalogue.php Merge branch '2.0' 2011-11-11 22:52:07 +01:00
MessageCatalogueInterface.php fixed CS 2012-07-09 14:54:20 +02:00
MessageSelector.php [Translation] fixed typo 2012-07-15 09:21:44 +02:00
phpunit.xml.dist [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
PluralizationRules.php fixed CS 2012-07-09 14:54:20 +02:00
README.md [Components] Tests/Autoloading fixes 2012-05-01 17:51:41 +02:00
Translator.php merged 2.0 2012-02-22 18:59:56 +01:00
TranslatorInterface.php fixed CS 2012-07-09 14:54:20 +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->setFallbackLocale('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.0/book/translation.html

You can run the unit tests with the following command:

phpunit

If you also want to run the unit tests that depend on other Symfony Components, install dev dependencies before running PHPUnit:

php composer.phar install --dev