diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 8457656f08a0d..4306af4a1c465 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -35,7 +35,7 @@ protected function configure() ->setName('translation:update') ->setDefinition(array( new InputArgument('locale', InputArgument::REQUIRED, 'The locale'), - new InputArgument('bundle', InputArgument::REQUIRED, 'The bundle where to load the messages'), + new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle where to load the messages, defaults to app/Resources folder', null), new InputOption( 'prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__' @@ -64,13 +64,18 @@ protected function configure() ->setDescription('Updates the translation file') ->setHelp(<<%command.name% command extract translation strings from templates -of a given bundle. It can display them or merge the new ones into the translation files. +of a given bundle or the app folder. It can display them or merge the new ones into the translation files. When new translation strings are found it can automatically add a prefix to the translation message. +Example running against a Bundle (AcmeBundle) php %command.full_name% --dump-messages en AcmeBundle php %command.full_name% --force --prefix="new_" fr AcmeBundle +Example running against app messages (app/Resources folder) +php %command.full_name% --dump-messages en +php %command.full_name% --force --prefix="new_" fr + EOF ) ; @@ -98,23 +103,33 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } + // Define Root Path to App folder + $rootPath = $this->getApplication()->getKernel()->getRootDir(); + $currentName = "app folder"; + + // Override with provided Bundle info + if (null !== $input->getArgument('bundle')) { + $foundBundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle')); + $rootPath = $foundBundle->getPath(); + $currentName = $foundBundle->getName(); + } + // get bundle directory - $foundBundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle')); - $bundleTransPath = $foundBundle->getPath().'/Resources/translations'; - $output->writeln(sprintf('Generating "%s" translation files for "%s"', $input->getArgument('locale'), $foundBundle->getName())); + $translationsPath = $rootPath.'/Resources/translations'; + $output->writeln(sprintf('Generating "%s" translation files for "%s"', $input->getArgument('locale'), $currentName)); // load any messages from templates $extractedCatalogue = new MessageCatalogue($input->getArgument('locale')); $output->writeln('Parsing templates'); $extractor = $this->getContainer()->get('translation.extractor'); $extractor->setPrefix($input->getOption('prefix')); - $extractor->extract($foundBundle->getPath().'/Resources/views/', $extractedCatalogue); + $extractor->extract($rootPath.'/Resources/views/', $extractedCatalogue); // load any existing messages from the translation files $currentCatalogue = new MessageCatalogue($input->getArgument('locale')); $output->writeln('Loading translation files'); $loader = $this->getContainer()->get('translation.loader'); - $loader->loadMessages($bundleTransPath, $currentCatalogue); + $loader->loadMessages($translationsPath, $currentCatalogue); // process catalogues $operation = $input->getOption('clean') @@ -150,7 +165,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // save the files if ($input->getOption('force') === true) { $output->writeln('Writing files'); - $writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath)); + $writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $translationsPath)); } } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy