Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cd50d7

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

File tree

3 files changed

+7
-6
lines changed
Filter options

3 files changed

+7
-6
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+4-3Lines changed: 4 additions & 3 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php
+1Lines changed: 1 addition & 0 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandCompletionTest.php
+2-3Lines changed: 2 additions & 3 deletions
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.