Merge branch '4.4' into 5.2
* 4.4: scan directories for translations sequentially
This commit is contained in:
commit
7866a0fbd6
@ -1220,16 +1220,17 @@ class FrameworkExtension extends Extension
|
||||
// Register translation resources
|
||||
if ($dirs) {
|
||||
$files = [];
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
$finder = Finder::create()
|
||||
->followLinks()
|
||||
->files()
|
||||
->filter(function (\SplFileInfo $file) {
|
||||
return 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
|
||||
})
|
||||
->in($dirs)
|
||||
->in($dir)
|
||||
->sortByName()
|
||||
;
|
||||
|
||||
foreach ($finder as $file) {
|
||||
$fileNameParts = explode('.', basename($file));
|
||||
$locale = $fileNameParts[\count($fileNameParts) - 2];
|
||||
@ -1239,6 +1240,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$files[$locale][] = (string) $file;
|
||||
}
|
||||
}
|
||||
|
||||
$projectDir = $container->getParameter('kernel.project_dir');
|
||||
|
||||
|
@ -836,6 +836,19 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$files,
|
||||
'->registerTranslatorConfiguration() finds translation resources with dots in domain'
|
||||
);
|
||||
$this->assertContains(strtr(__DIR__.'/translations/security.en.yaml', '/', \DIRECTORY_SEPARATOR), $files);
|
||||
|
||||
$positionOverridingTranslationFile = array_search(strtr(realpath(__DIR__.'/translations/security.en.yaml'), '/', \DIRECTORY_SEPARATOR), $files);
|
||||
|
||||
if (false !== $positionCoreTranslationFile = array_search(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files)) {
|
||||
$this->assertContains(strtr(realpath(__DIR__.'/../../../../Component/Security/Core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
|
||||
} else {
|
||||
$this->assertContains(strtr(realpath(__DIR__.'/../../vendor/symfony/security-core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
|
||||
|
||||
$positionCoreTranslationFile = array_search(strtr(realpath(__DIR__.'/../../vendor/symfony/security-core/Resources/translations/security.en.xlf'), '/', \DIRECTORY_SEPARATOR), $files);
|
||||
}
|
||||
|
||||
$this->assertGreaterThan($positionCoreTranslationFile, $positionOverridingTranslationFile);
|
||||
|
||||
$calls = $container->getDefinition('translator.default')->getMethodCalls();
|
||||
$this->assertEquals(['fr'], $calls[1][1][0]);
|
||||
|
@ -52,6 +52,7 @@
|
||||
"symfony/mime": "^4.4|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"symfony/security-bundle": "^5.1",
|
||||
"symfony/security-core": "^4.4|^5.2",
|
||||
"symfony/security-csrf": "^4.4|^5.0",
|
||||
"symfony/security-http": "^4.4|^5.0",
|
||||
"symfony/serializer": "^5.2",
|
||||
|
Reference in New Issue
Block a user