Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2c82e5

Browse files
committed
[FrameworkBundle] Added 'path' option to 'debug:translation' command
This enables not only to inspect Bundles, but also directories, like the app/ directory for instance.
1 parent b52e0d1 commit f2c82e5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ protected function configure()
4545
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'),
4646
new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Displays only missing messages'),
4747
new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Displays only unused messages'),
48+
new InputOption('path', 'p', InputOption::VALUE_NONE, 'Treats bundle name as path'),
4849
))
4950
->setDescription('Displays translation messages informations')
5051
->setHelp(<<<EOF
@@ -68,6 +69,10 @@ protected function configure()
6869
6970
<info>php %command.full_name% --only-unused en AcmeDemoBundle</info>
7071
72+
You can also use the command to inspect your <comment>app/</comment> directory:
73+
74+
<info>php %command.full_name% --path en app/</info>
75+
7176
EOF
7277
)
7378
;
@@ -80,17 +85,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
8085
{
8186
$locale = $input->getArgument('locale');
8287
$domain = $input->getOption('domain');
83-
$bundle = $this->getContainer()->get('kernel')->getBundle($input->getArgument('bundle'));
88+
89+
if ($input->getOption('path')) {
90+
$bundlePath = $input->getArgument('bundle');
91+
} else {
92+
$bundlePath = $this->getContainer()->get('kernel')->getBundle($input->getArgument('bundle'))->getPath();
93+
}
8494
$loader = $this->getContainer()->get('translation.loader');
8595

8696
// Extract used messages
8797
$extractedCatalogue = new MessageCatalogue($locale);
88-
$this->getContainer()->get('translation.extractor')->extract($bundle->getPath().'/Resources/views', $extractedCatalogue);
98+
$this->getContainer()->get('translation.extractor')->extract($bundlePath.'/Resources/views', $extractedCatalogue);
8999

90100
// Load defined messages
91101
$currentCatalogue = new MessageCatalogue($locale);
92-
if (is_dir($bundle->getPath().'/Resources/translations')) {
93-
$loader->loadMessages($bundle->getPath().'/Resources/translations', $currentCatalogue);
102+
if (is_dir($bundlePath.'/Resources/translations')) {
103+
$loader->loadMessages($bundlePath.'/Resources/translations', $currentCatalogue);
94104
}
95105

96106
// Merge defined and extracted messages to get all message ids
@@ -123,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
123133
}
124134

125135
$fallbackCatalogue = new MessageCatalogue($fallbackLocale);
126-
$loader->loadMessages($bundle->getPath().'/Resources/translations', $fallbackCatalogue);
136+
$loader->loadMessages($bundlePath.'/Resources/translations', $fallbackCatalogue);
127137
$fallbackCatalogues[] = $fallbackCatalogue;
128138
}
129139
}

0 commit comments

Comments
 (0)