[Translation][update cmd] taken account into bundle overrides path.
This commit is contained in:
parent
3d16094e5b
commit
a8f315b8dd
@ -61,6 +61,8 @@ EOF
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$kernel = $this->getContainer()->get('kernel');
|
||||||
|
|
||||||
// check presence of force or dump-message
|
// check presence of force or dump-message
|
||||||
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
|
if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
|
||||||
$output->writeln('<info>You must choose one of --force or --dump-messages</info>');
|
$output->writeln('<info>You must choose one of --force or --dump-messages</info>');
|
||||||
@ -79,8 +81,12 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get bundle directory
|
// get bundle directory
|
||||||
$foundBundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
|
$foundBundle = $kernel->getBundle($input->getArgument('bundle'));
|
||||||
$bundleTransPath = $foundBundle->getPath().'/Resources/translations';
|
$bundleTransPaths = array(
|
||||||
|
$foundBundle->getPath().'/Resources/',
|
||||||
|
sprintf('%s/Resources/%s/', $kernel->getRootDir(), $foundBundle->getName()),
|
||||||
|
);
|
||||||
|
|
||||||
$output->writeln(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $foundBundle->getName()));
|
$output->writeln(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $foundBundle->getName()));
|
||||||
|
|
||||||
// load any messages from templates
|
// load any messages from templates
|
||||||
@ -88,13 +94,23 @@ EOF
|
|||||||
$output->writeln('Parsing templates');
|
$output->writeln('Parsing templates');
|
||||||
$extractor = $this->getContainer()->get('translation.extractor');
|
$extractor = $this->getContainer()->get('translation.extractor');
|
||||||
$extractor->setPrefix($input->getOption('prefix'));
|
$extractor->setPrefix($input->getOption('prefix'));
|
||||||
$extractor->extract($foundBundle->getPath().'/Resources/views/', $extractedCatalogue);
|
foreach ($bundleTransPaths as $path) {
|
||||||
|
$path = $path.'views';
|
||||||
|
if (is_dir($path)) {
|
||||||
|
$extractor->extract($path, $extractedCatalogue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load any existing messages from the translation files
|
// load any existing messages from the translation files
|
||||||
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||||
$output->writeln('Loading translation files');
|
$output->writeln('Loading translation files');
|
||||||
$loader = $this->getContainer()->get('translation.loader');
|
$loader = $this->getContainer()->get('translation.loader');
|
||||||
$loader->loadMessages($bundleTransPath, $currentCatalogue);
|
foreach ($bundleTransPaths as $path) {
|
||||||
|
$path = $path.'translations';
|
||||||
|
if (is_dir($path)) {
|
||||||
|
$loader->loadMessages($path, $currentCatalogue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// process catalogues
|
// process catalogues
|
||||||
$operation = $input->getOption('clean')
|
$operation = $input->getOption('clean')
|
||||||
@ -133,7 +149,17 @@ EOF
|
|||||||
// save the files
|
// save the files
|
||||||
if ($input->getOption('force') === true) {
|
if ($input->getOption('force') === true) {
|
||||||
$output->writeln('Writing files');
|
$output->writeln('Writing files');
|
||||||
|
$bundleTransPath = false;
|
||||||
|
foreach ($bundleTransPaths as $path) {
|
||||||
|
$path = $path.'translations';
|
||||||
|
if (is_dir($path)) {
|
||||||
|
$bundleTransPath = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bundleTransPath) {
|
||||||
$writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath));
|
$writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user