diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 8236d581c2e5d..21e43e6f60a12 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -700,11 +700,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder foreach ($finder as $file) { list($domain, $locale, $format) = explode('.', $file->getBasename(), 3); - if (!isset($files[$locale])) { - $files[$locale] = array(); - } - - $files[$locale][] = (string) $file; + $files[] = (string) $file; } $translator->replaceArgument(4, $files); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index b4ceee8252b23..ba3d6bdefed24 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -225,7 +225,7 @@ public function testTranslator() $this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator'); $resources = $container->getDefinition('translator.default')->getArgument(4); - $files = array_map(function ($resource) { return realpath($resource); }, $resources['en']); + $files = array_map(function ($resource) { return realpath($resource); }, $resources); $ref = new \ReflectionClass('Symfony\Component\Validator\Validation'); $this->assertContains( strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 1da8faea5433d..e2a3dafab22bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -106,9 +106,7 @@ public function testLoadRessourcesWithCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( - 'fr' => array( - __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), + __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ); // prime the cache @@ -134,9 +132,7 @@ public function testLoadRessourcesWithoutCaching() { $loader = new \Symfony\Component\Translation\Loader\YamlFileLoader(); $resourceFiles = array( - 'fr' => array( - __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', - ), + __DIR__.'/../Fixtures/Resources/translations/messages.fr.yml', ); $translator = $this->getTranslator($loader, array(), $resourceFiles, 'yml'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 3d0f2b04e19f7..cd5a9b5cc574f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -59,20 +59,11 @@ public function __construct(ContainerInterface $container, MessageSelector $sele } $this->options = array_merge($this->options, $options); - - parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']); - } - - /** - * {@inheritdoc} - */ - protected function loadCatalogue($locale) - { if (null !== $this->options['cache_dir'] && $this->options['debug']) { - $this->loadResources($locale); + $this->loadResources(); } - parent::loadCatalogue($locale); + parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']); } /** @@ -81,12 +72,12 @@ protected function loadCatalogue($locale) protected function initializeCatalogue($locale) { $this->initialize(); - $this->loadResources($locale); parent::initializeCatalogue($locale); } protected function initialize() { + $this->loadResources(); foreach ($this->loaderIds as $id => $aliases) { foreach ($aliases as $alias) { $this->addLoader($alias, $this->container->get($id)); @@ -94,18 +85,13 @@ protected function initialize() } } - private function loadResources($locale) + private function loadResources() { - $locales = array_merge(array($locale), $this->computeFallbackLocales($locale)); - foreach ($locales as $locale) { - if (isset($this->resourceFiles[$locale])) { - foreach ($this->resourceFiles[$locale] as $file) { - // filename is domain.locale.format - list($domain, $locale, $format) = explode('.', basename($file), 3); - $this->addResource($format, $file, $locale, $domain); - } - unset($this->resourceFiles[$locale]); - } + foreach ($this->resourceFiles as $key => $file) { + // filename is domain.locale.format + list($domain, $locale, $format) = explode('.', basename($file), 3); + $this->addResource($format, $file, $locale, $domain); + unset($this->resourceFiles[$key]); } } }