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 e5d476b

Browse filesBrowse files
committed
scan directories for translations sequentially
1 parent f1a7dca commit e5d476b
Copy full SHA for e5d476b

File tree

3 files changed

+25
-16
lines changed
Filter options

3 files changed

+25
-16
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+18-16Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,24 +1236,26 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
12361236
// Register translation resources
12371237
if ($dirs) {
12381238
$files = [];
1239-
$finder = Finder::create()
1240-
->followLinks()
1241-
->files()
1242-
->filter(function (\SplFileInfo $file) {
1243-
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
1244-
})
1245-
->in($dirs)
1246-
->sortByName()
1247-
;
12481239

1249-
foreach ($finder as $file) {
1250-
$fileNameParts = explode('.', basename($file));
1251-
$locale = $fileNameParts[\count($fileNameParts) - 2];
1252-
if (!isset($files[$locale])) {
1253-
$files[$locale] = [];
1254-
}
1240+
foreach ($dirs as $dir) {
1241+
$finder = Finder::create()
1242+
->followLinks()
1243+
->files()
1244+
->filter(function (\SplFileInfo $file) {
1245+
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
1246+
})
1247+
->in($dir)
1248+
->sortByName()
1249+
;
1250+
foreach ($finder as $file) {
1251+
$fileNameParts = explode('.', basename($file));
1252+
$locale = $fileNameParts[\count($fileNameParts) - 2];
1253+
if (!isset($files[$locale])) {
1254+
$files[$locale] = [];
1255+
}
12551256

1256-
$files[$locale][] = (string) $file;
1257+
$files[$locale][] = (string) $file;
1258+
}
12571259
}
12581260

12591261
$projectDir = $container->getParameter('kernel.project_dir');

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,13 @@ public function testTranslator()
877877
$files,
878878
'->registerTranslatorConfiguration() finds translation resources with dots in domain'
879879
);
880+
$this->assertContains(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
881+
$this->assertContains(strtr(__DIR__.'/translations/security.en.yaml', '/', \DIRECTORY_SEPARATOR), $files);
882+
883+
$positionCoreTranslationFile = array_search(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
884+
$positionOverridingTranslationFile = array_search(strtr(realpath(__DIR__.'/translations/security.en.yaml'), '/', \DIRECTORY_SEPARATOR), $files);
885+
886+
$this->assertGreaterThan($positionCoreTranslationFile, $positionOverridingTranslationFile);
880887

881888
$calls = $container->getDefinition('translator.default')->getMethodCalls();
882889
$this->assertEquals(['fr'], $calls[1][1][0]);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/translations/security.en.yaml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/translations/security.en.yaml
Whitespace-only changes.

0 commit comments

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