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 89e86197c1 minor #17480 Static code analysis (Koc)
This PR was merged into the 2.3 branch.

Discussion
----------

Static code analysis

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

Things that done:
* fix case in method calls
* removed unused imports
* use shorter concat where it possible
* optimize some css
* removed duplicated array keys
* removed redurant return statements
* removed one-time variables
* do not pass arguments that not used in functions

Commits
-------

8db691a Static code analysis
2016-01-27 05:57:57 +01:00
..
Catalogue Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
Dumper Static code analysis 2016-01-25 19:00:36 +02:00
Exception remove api tags from code 2015-09-28 19:11:22 +02:00
Extractor made {@inheritdoc} annotations consistent across the board 2014-04-16 09:04:20 +02:00
Loader [Translation][Csv file] remove unnecessary statements, for better readability. 2015-10-23 09:44:09 +00:00
Tests fixed test 2016-01-21 09:40:05 +01:00
Writer [2.3] Static Code Analysis for Components 2015-12-31 19:24:01 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md updated various CHANGELOG files that were not updated when the PRs were merged 2013-03-23 08:35:36 +01:00
composer.json added the new Composer exclude-from-classmap option 2015-10-30 12:48:51 -07:00
IdentityTranslator.php remove api tags from code 2015-09-28 19:11:22 +02:00
Interval.php Docblock fixes 2014-11-30 13:33:44 +00:00
LICENSE Update copyright year 2016-01-01 23:53:47 -03:00
MessageCatalogue.php remove api tags from code 2015-09-28 19:11:22 +02:00
MessageCatalogueInterface.php remove api tags from code 2015-09-28 19:11:22 +02:00
MessageSelector.php remove api tags from code 2015-09-28 19:11:22 +02:00
MetadataAwareInterface.php Fix doc blocks 2014-04-18 22:17:16 +02:00
phpunit.xml.dist Add missing exclusions from phpunit.xml.dist 2015-11-18 09:19:46 +01:00
PluralizationRules.php The following change adds support for Armenian pluralization. 2015-11-12 10:09:48 +01:00
README.md use new repo location in some readme.md 2015-09-03 22:55:07 +02:00
Translator.php remove api tags from code 2015-09-28 19:11:22 +02:00
TranslatorInterface.php remove api tags from code 2015-09-28 19:11:22 +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/silexphp/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php

Documentation:

https://symfony.com/doc/2.3/book/translation.html

You can run the unit tests with the following command:

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