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 2c4b5e5bbe Merge branch '2.3' into 2.6
* 2.3:
  [Validator] Add missing pt_BR translations
  Add parsing of hexadecimal strings for PHP 7
  [Configuration] improve description for ignoreExtraKeys on ArrayNodeDefinition
  [Validator] Added missing Hungarian translation
  [Validator] Fixed grammar in Hungarian translation
  CS: Unary operators should be placed adjacent to their operands
  CS: Binary operators should be arounded by at least one space
  remove useless tests that fail in php 7
  [Translator] fix test for php 7 compatibility
  Update phpdoc of ProcessBuilder#setPrefix()

Conflicts:
	src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php
	src/Symfony/Component/PropertyAccess/PropertyAccessor.php
	src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf
	src/Symfony/Component/Yaml/Parser.php
2015-03-30 17:54:10 +02:00
..
Catalogue Merge branch '2.5' 2014-10-26 08:46:28 +01:00
Dumper Merge branch '2.5' 2014-10-26 08:46:28 +01: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.3' into 2.6 2015-03-30 17:54:10 +02:00
Tests Merge branch '2.3' into 2.6 2015-03-30 17:54:10 +02:00
Writer Merge branch '2.3' into 2.5 2014-12-22 17:16:14 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Translation][changelog] fix typo. 2014-09-24 09:44:29 +01:00
composer.json Merge branch '2.3' into 2.6 2015-02-24 12:52:21 +01:00
IdentityTranslator.php [Translation] make IdentityTranslater consistent with normal translator 2013-11-20 03:31:35 +01: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
LoggingTranslator.php [Translator][Logging] implement TranslatorBagInterface. 2015-02-10 13:48:21 +00:00
MessageCatalogue.php unified return null usages 2014-04-16 09:43:51 +02:00
MessageCatalogueInterface.php Docblock fixes 2014-11-30 13:33:44 +00:00
MessageSelector.php Merge branch '2.3' into 2.5 2014-12-02 21:15:53 +01: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 CS: Convert double quotes to single quotes 2015-03-21 12:11:30 +01:00
README.md Merge branch '2.3' into 2.6 2015-02-11 08:12:14 +01:00
Translator.php [translation][initialize cache] Remove dead code. 2015-03-14 11:42:25 +00:00
TranslatorBagInterface.php [Translation] added LoggingTranslator. 2014-09-24 10:36:39 +02: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/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 install
$ phpunit