Skip to content

Commit

Permalink
Only support correctly formatted language folders
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Jul 5, 2021
1 parent de7b8d7 commit c2ca955
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core-bundle/src/DependencyInjection/Configuration.php
Expand Up @@ -12,6 +12,7 @@

namespace Contao\CoreBundle\DependencyInjection;

use Contao\CoreBundle\Util\LocaleUtil;
use Contao\Image\ResizeConfiguration;
use Imagine\Image\ImageInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
Expand Down Expand Up @@ -514,10 +515,16 @@ private function getLocales(): array
$languages = [$this->defaultLocale];

/** @var array<SplFileInfo> $finder */
$finder = Finder::create()->directories()->depth(0)->name('/^[a-z]{2}(_[A-Z]{2})?$/')->in($dirs);
$finder = Finder::create()->directories()->depth(0)->name('/^[a-z]{2,}/')->in($dirs);

foreach ($finder as $file) {
$languages[] = $file->getFilename();
$locale = $file->getFilename();

if (LocaleUtil::canonicalize($locale) !== $locale) {
continue;
}

$languages[] = $locale;
}

return array_values(array_unique($languages));
Expand Down

0 comments on commit c2ca955

Please sign in to comment.