Daniel ab1334c0cf the whole shebang | 10 سال پیش | |
---|---|---|
.. | ||
Catalogue | 10 سال پیش | |
Dumper | 10 سال پیش | |
Exception | 10 سال پیش | |
Extractor | 10 سال پیش | |
Loader | 10 سال پیش | |
Tests | 10 سال پیش | |
Writer | 10 سال پیش | |
.gitignore | 10 سال پیش | |
CHANGELOG.md | 10 سال پیش | |
IdentityTranslator.php | 10 سال پیش | |
Interval.php | 10 سال پیش | |
LICENSE | 10 سال پیش | |
MessageCatalogue.php | 10 سال پیش | |
MessageCatalogueInterface.php | 10 سال پیش | |
MessageSelector.php | 10 سال پیش | |
MetadataAwareInterface.php | 10 سال پیش | |
PluralizationRules.php | 10 سال پیش | |
README.md | 10 سال پیش | |
Translator.php | 10 سال پیش | |
TranslatorInterface.php | 10 سال پیش | |
composer.json | 10 سال پیش | |
phpunit.xml.dist | 10 سال پیش |
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";
Silex integration:
https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/TranslationServiceProvider.php
Documentation:
http://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.phar install --dev
$ phpunit