[FrameworkBundle] fixed translation loading process when a file does not respect the expected pattern (avoid loading foo.fr.xliff~ for instance)

This commit is contained in:
Fabien Potencier 2011-07-13 09:23:43 +02:00
parent 451c737b97
commit 68c07775ad

View File

@ -490,7 +490,9 @@ class FrameworkExtension extends Extension
// Register translation resources // Register translation resources
if ($dirs) { if ($dirs) {
$finder = new Finder(); $finder = new Finder();
$finder->files()->filter(function (\SplFileInfo $file) { return 2 === substr_count($file->getBasename(), '.'); })->in($dirs); $finder->files()->filter(function (\SplFileInfo $file) {
return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
})->in($dirs);
foreach ($finder as $file) { foreach ($finder as $file) {
// filename is domain.locale.format // filename is domain.locale.format
list($domain, $locale, $format) = explode('.', $file->getBasename()); list($domain, $locale, $format) = explode('.', $file->getBasename());