-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Translator] scan directories for translations sequentially #40116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1236,24 +1236,26 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder | |
// Register translation resources | ||
if ($dirs) { | ||
$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) { | ||
$fileNameParts = explode('.', basename($file)); | ||
$locale = $fileNameParts[\count($fileNameParts) - 2]; | ||
if (!isset($files[$locale])) { | ||
$files[$locale] = []; | ||
} | ||
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($dir) | ||
->sortByName() | ||
; | ||
foreach ($finder as $file) { | ||
$fileNameParts = explode('.', basename($file)); | ||
$locale = $fileNameParts[\count($fileNameParts) - 2]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion : Wouldn't $info->getBasename($info->getExtension())) give us the locale? Assuming the filer is only matching patterns such as 'ar.json'? I would remove the need for the explode and fileparts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That code was here before. I suggest not to change it as part of this bugfix. |
||
if (!isset($files[$locale])) { | ||
$files[$locale] = []; | ||
} | ||
|
||
$files[$locale][] = (string) $file; | ||
$files[$locale][] = (string) $file; | ||
} | ||
} | ||
|
||
$projectDir = $container->getParameter('kernel.project_dir'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for using basename over $file->getBasename()?