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