Skip to content

Commit 2c5ed14

Browse files
committed
Fixed default value for locales in translation push|pull commands
1 parent 1f9dbf9 commit 2c5ed14

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,24 +1360,28 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
13601360
return;
13611361
}
13621362

1363-
foreach ($config['providers'] as $name => $provider) {
1364-
if (!$config['enabled_locales'] && !$provider['locales']) {
1365-
throw new LogicException(sprintf('You must specify one of "framework.translator.enabled_locales" or "framework.translator.providers.%s.locales" in order to use translation providers.', $name));
1363+
$locales = $config['enabled_locales'] ?? [];
1364+
1365+
foreach ($config['providers'] as $provider) {
1366+
if ($provider['locales']) {
1367+
$locales += $provider['locales'];
13661368
}
13671369
}
13681370

1371+
$locales = array_unique($locales);
1372+
13691373
$container->getDefinition('console.command.translation_pull')
13701374
->replaceArgument(4, array_merge($transPaths, [$config['default_path']]))
1371-
->replaceArgument(5, $config['enabled_locales'])
1375+
->replaceArgument(5, $locales)
13721376
;
13731377

13741378
$container->getDefinition('console.command.translation_push')
13751379
->replaceArgument(2, array_merge($transPaths, [$config['default_path']]))
1376-
->replaceArgument(3, $config['enabled_locales'])
1380+
->replaceArgument(3, $locales)
13771381
;
13781382

13791383
$container->getDefinition('translation.provider_collection_factory')
1380-
->replaceArgument(1, $config['enabled_locales'])
1384+
->replaceArgument(1, $locales)
13811385
;
13821386

13831387
$container->getDefinition('translation.provider_collection')->setArgument(0, $config['providers']);

0 commit comments

Comments
 (0)