8000 modifying locale completion for only enabled locales, and inject duri… · symfony/symfony@6cd50d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cd50d7

Browse files
committed
modifying locale completion for only enabled locales, and inject during config/console for the enabled locales value
1 parent 7cfc2b8 commit 6cd50d7

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Symfony\Component\Console\Style\SymfonyStyle;
2323
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
2424
use Symfony\Component\HttpKernel\KernelInterface;
25-
use Symfony\Component\Intl\Locales;
2625
use Symfony\Component\Translation\Catalogue\MergeOperation;
2726
use Symfony\Component\Translation\Catalogue\TargetOperation;
2827
use Symfony\Component\Translation\Extractor\ExtractorInterface;
@@ -60,8 +59,9 @@ class TranslationUpdateCommand extends Command
6059
private $defaultViewsPath;
6160
private $transPaths;
6261
private $codePaths;
62+
private $enabledLocales;
6363

64-
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [])
64+
public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = [], array $enabledLocales = [])
6565
{
6666
parent::__construct();
6767

@@ -73,6 +73,7 @@ public function __construct(TranslationWriterInterface $writer, TranslationReade
7373
$this->defaultViewsPath = $defaultViewsPath;
7474
$this->transPaths = $transPaths;
7575
$this->codePaths = $codePaths;
76+
$this->enabledLocales = $enabledLocales;
7677
}
7778

7879
/**
@@ -311,7 +312,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
311312
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
312313
{
313314
if ($input->mustSuggestArgumentValuesFor('locale')) {
314-
$suggestions->suggestValues(Locales::getLocales());
315+
$suggestions->suggestValues($this->enabledLocales);
315316

316317
return;
317318
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
null, // twig.default_path
237237
[], // Translator paths
238238
[], // Twig paths
239+
param('kernel.enabled_locales'),
239240
])
240241
->tag('console.command')
241242

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Filesystem\Filesystem;
2121
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
2222
use Symfony\Component\HttpKernel\KernelInterface;
23-
use Symfony\Component\Intl\Locales;
2423
use Symfony\Component\Translation\Extractor\ExtractorInterface;
2524
use Symfony\Component\Translation\Reader\TranslationReader;
2625
use Symfony\Component\Translation\Translator;
@@ -45,7 +44,7 @@ public function testComplete(array $input, array $expectedSuggestions)
4544

4645
public function provideCompletionSuggestions()
4746
{
48-
yield 'locale' => [[''], Locales::getLocales()];
47+
yield 'locale' => [[''], ['en', 'fr']];
4948
yield 'bundle' => [['en', ''], ['BaseBundle']];
5049
yield 'domain with locale' => [['en', '--domain=m'], ['messages']];
5150
yield 'domain without locale' => [['--domain=m'], []];
@@ -127,7 +126,7 @@ function ($path, $catalogue) use ($loadedMessages) {
127126
->method('getContainer')
128127
->willReturn($container);
129128

130-
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $codePaths);
129+
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $codePaths, ['en', 'fr']);
131130

132131
$application = new Application($kernel);
133132
$application->add($command);

0 commit comments

Comments
 (0)
0