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)
PHP

minor #14365 [3.0]Closures support $this in PHP >= 5.4 (dosten)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[3.0]Closures support $this in PHP >= 5.4

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Closures support `$this` in PHP >= 5.4

ping @aitboudad

Commits
-------

38f32c1 $this can be used inside a closure in PHP >= 5.4
latest commit 3ba54181c8
@fabpot fabpot authored
Failed to load latest commit information.
Catalogue Merge branch '2.5'
DataCollector [Translation][Profiler] reduce memory usage for collected messages.
Dumper Do not override PHP constants, only use when available
Exception [Translation] uniformized the way exception are thrown in LoaderInter…
Extractor [Translation][Extractor] Allow extracting an array of files besides e…
Loader Merge branch '2.7' into 2.8
Tests Merge branch '2.8'
Writer Merge branch '2.3' into 2.5
.gitignore Added missing files .gitignore
CHANGELOG.md Merge branch '2.7' into 2.8
DataCollectorTranslator.php [2.7][Translation] remove duplicate code for loading catalogue.
IdentityTranslator.php [Translation] make IdentityTranslater consistent with normal translator
Interval.php Docblock fixes
LICENSE Updated copyright to 2015
LoggingTranslator.php [2.6][Translation] remove duplicate code for loading catalogue.
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.8'
Translator.php $this can be used inside a closure in PHP >= 5.4
TranslatorBagInterface.php [2.6][Translation] remove duplicate code for loading catalogue.
TranslatorInterface.php Merge branch '2.3' into 2.4
composer.json Merge branch '2.8'
phpunit.xml.dist [2.3] require-dev PHPUnit bridge

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:

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