diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 8cb80babe61c..ed1e6b261103 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -55,9 +55,9 @@ class TranslationDebugCommand extends Command private $defaultTransPath; private $defaultViewsPath; private $transPaths; - private $viewsPaths; + private $codePaths; - public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $viewsPaths = []) + public function __construct(TranslatorInterface $translator, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = []) { parent::__construct(); @@ -67,7 +67,7 @@ public function __construct(TranslatorInterface $translator, TranslationReaderIn $this->defaultTransPath = $defaultTransPath; $this->defaultViewsPath = $defaultViewsPath; $this->transPaths = $transPaths; - $this->viewsPaths = $viewsPaths; + $this->codePaths = $codePaths; } /** @@ -139,9 +139,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - $viewsPaths = $this->viewsPaths; + $codePaths = $this->codePaths; + $codePaths[] = $kernel->getProjectDir().'/src'; if ($this->defaultViewsPath) { - $viewsPaths[] = $this->defaultViewsPath; + $codePaths[] = $this->defaultViewsPath; } // Override with provided Bundle info @@ -150,19 +151,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $bundle = $kernel->getBundle($input->getArgument('bundle')); $bundleDir = $bundle->getPath(); $transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations']; - $viewsPaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; + $codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } if ($this->defaultViewsPath) { - $viewsPaths[] = $this->defaultViewsPath; + $codePaths[] = $this->defaultViewsPath; } } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - $viewsPaths = [$path.'/templates']; + $codePaths = [$path.'/templates']; if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); @@ -172,12 +173,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($kernel->getBundles() as $bundle) { $bundleDir = $bundle->getPath(); $transPaths[] = is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundle->getPath().'/translations'; - $viewsPaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates'; + $codePaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates'; } } // Extract used messages - $extractedCatalogue = $this->extractMessages($locale, $viewsPaths); + $extractedCatalogue = $this->extractMessages($locale, $codePaths); // Load defined messages $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 5f61f7f7fbeb..39dcc30a6019 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -51,9 +51,9 @@ class TranslationUpdateCommand extends Command private $defaultTransPath; private $defaultViewsPath; private $transPaths; - private $viewsPaths; + private $codePaths; - public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $viewsPaths = []) + public function __construct(TranslationWriterInterface $writer, TranslationReaderInterface $reader, ExtractorInterface $extractor, string $defaultLocale, string $defaultTransPath = null, string $defaultViewsPath = null, array $transPaths = [], array $codePaths = []) { parent::__construct(); @@ -64,7 +64,7 @@ public function __construct(TranslationWriterInterface $writer, TranslationReade $this->defaultTransPath = $defaultTransPath; $this->defaultViewsPath = $defaultViewsPath; $this->transPaths = $transPaths; - $this->viewsPaths = $viewsPaths; + $this->codePaths = $codePaths; } /** @@ -150,9 +150,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - $viewsPaths = $this->viewsPaths; + $codePaths = $this->codePaths; + $codePaths[] = $kernel->getProjectDir().'/src'; if ($this->defaultViewsPath) { - $viewsPaths[] = $this->defaultViewsPath; + $codePaths[] = $this->defaultViewsPath; } $currentName = 'default directory'; @@ -162,12 +163,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $foundBundle = $kernel->getBundle($input->getArgument('bundle')); $bundleDir = $foundBundle->getPath(); $transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations']; - $viewsPaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; + $codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates']; if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } if ($this->defaultViewsPath) { - $viewsPaths[] = $this->defaultViewsPath; + $codePaths[] = $this->defaultViewsPath; } $currentName = $foundBundle->getName(); } catch (\InvalidArgumentException $e) { @@ -175,7 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - $viewsPaths = [$path.'/templates']; + $codePaths = [$path.'/templates']; if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); @@ -190,7 +191,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $extractedCatalogue = new MessageCatalogue($input->getArgument('locale')); $io->comment('Parsing templates...'); $this->extractor->setPrefix($input->getOption('prefix')); - foreach ($viewsPaths as $path) { + foreach ($codePaths as $path) { if (is_dir($path) || is_file($path)) { $this->extractor->extract($path, $extractedCatalogue); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 2bdbcbf44753..5cdf62e47006 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -139,7 +139,7 @@ protected function tearDown(): void $this->fs->remove($this->translationDir); } - private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $viewsPaths = []): CommandTester + private function createCommandTester($extractedMessages = [], $loadedMessages = [], $kernel = null, array $transPaths = [], array $codePaths = []): CommandTester { $translator = $this->createMock(Translator::class); $translator @@ -190,7 +190,7 @@ function ($path, $catalogue) use ($loadedMessages) { ->method('getContainer') ->willReturn($container); - $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths); + $command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $codePaths); $application = new Application($kernel); $application->add($command); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 7e1c90d051f6..35ce89f63887 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -148,7 +148,7 @@ protected function tearDown(): void /** * @return CommandTester */ - private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $viewsPaths = []) + private function createCommandTester($extractedMessages = [], $loadedMessages = [], KernelInterface $kernel = null, array $transPaths = [], array $codePaths = []) { $translator = $this->createMock(Translator::class); $translator @@ -209,7 +209,7 @@ function ($path, $catalogue) use ($loadedMessages) { ->method('getContainer') ->willReturn($container); - $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths); + $command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $codePaths); $application = new Application($kernel); $application->add($command);
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: