Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa70a94

Browse filesBrowse files
committed
[Translation] keep old array structure of resourcesFiles to avoid BC.
1 parent 1a4d7d7 commit aa70a94
Copy full SHA for aa70a94

File tree

Expand file treeCollapse file tree

4 files changed

+13
-35
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+13
-35
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
700700

701701
foreach ($finder as $file) {
702702
list($domain, $locale, $format) = explode('.', $file->getBasename(), 3);
703-
if (!isset($files[$locale])) {
704-
$files[$locale] = array();
705-
}
706-
707-
$files[$locale][] = (string) $file;
703+
$files[] = (string) $file;
708704
}
709705

710706
$translator->replaceArgument(4, $files);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function testTranslator()
225225
$this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator');
226226
$resources = $container->getDefinition('translator.default')->getArgument(4);
227227

228-
$files = array_map(function ($resource) { return realpath($resource); }, $resources['en']);
228+
$files = array_map(function ($resource) { return realpath($resource); }, $resources);
229229
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
230230
$this->assertContains(
231231
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),

‎src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ public function testLoadRessourcesWithCaching()
106106
{
107107
$loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
108108
$resourceFiles = array(
109-
'fr' => array(
110-
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
111-
),
109+
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
112110
);
113111

114112
// prime the cache
@@ -134,9 +132,7 @@ public function testLoadRessourcesWithoutCaching()
134132
{
135133
$loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
136134
$resourceFiles = array(
137-
'fr' => array(
138-
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
139-
),
135+
__DIR__.'/../Fixtures/Resources/translations/messages.fr.yml',
140136
);
141137

142138
$translator = $this->getTranslator($loader, array(), $resourceFiles, 'yml');

‎src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
+9-23Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,11 @@ public function __construct(ContainerInterface $container, MessageSelector $sele
5959
}
6060

6161
$this->options = array_merge($this->options, $options);
62-
63-
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
64-
}
65-
66-
/**
67-
* {@inheritdoc}
68-
*/
69-
protected function loadCatalogue($locale)
70-
{
7162
if (null !== $this->options['cache_dir'] && $this->options['debug']) {
72-
$this->loadResources($locale);
63+
$this->loadResources();
7364
}
7465

75-
parent::loadCatalogue($locale);
66+
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
7667
}
7768

7869
/**
@@ -81,31 +72,26 @@ protected function loadCatalogue($locale)
8172
protected function initializeCatalogue($locale)
8273
{
8374
$this->initialize();
84-
$this->loadResources($locale);
8575
parent::initializeCatalogue($locale);
8676
}
8777

8878
protected function initialize()
8979
{
80+
$this->loadResources();
9081
foreach ($this->loaderIds as $id => $aliases) {
9182
foreach ($aliases as $alias) {
9283
$this->addLoader($alias, $this->container->get($id));
9384
}
9485
}
9586
}
9687

97-
private function loadResources($locale)
88+
private function loadResources()
9889
{
99-
$locales = array_merge(array($locale), $this->computeFallbackLocales($locale));
100-
foreach ($locales as $locale) {
101-
if (isset($this->resourceFiles[$locale])) {
102-
foreach ($this->resourceFiles[$locale] as $file) {
103-
// filename is domain.locale.format
104-
list($domain, $locale, $format) = explode('.', basename($file), 3);
105-
$this->addResource($format, $file, $locale, $domain);
106-
}
107-
unset($this->resourceFiles[$locale]);
108-
}
90+
foreach ($this->resourceFiles as $key => $file) {
91+
// filename is domain.locale.format
92+
list($domain, $locale, $format) = explode('.', basename($file), 3);
93+
$this->addResource($format, $file, $locale, $domain);
94+
unset($this->resourceFiles[$key]);
10995
}
11096
}
11197
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.