bug #15038 [Translation][debug cmd] taken account into bundle overrides path. (aitboudad)

This PR was merged into the 2.6 branch.

Discussion
----------

[Translation][debug cmd] taken account into bundle overrides path.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets  | #14942 (partially)
| Tests pass?   | yes
| License       | MIT

Commits
-------

c3a077a [Translation][debug cmd] taken account into bundle overrides path.
This commit is contained in:
Fabien Potencier 2015-06-21 22:20:15 +02:00
commit e64b9bbcbd

View File

@ -83,17 +83,31 @@ EOF
{
$locale = $input->getArgument('locale');
$domain = $input->getOption('domain');
$bundle = $this->getContainer()->get('kernel')->getBundle($input->getArgument('bundle'));
$kernel = $this->getContainer()->get('kernel');
$bundle = $kernel->getBundle($input->getArgument('bundle'));
$loader = $this->getContainer()->get('translation.loader');
// Extract used messages
$extractedCatalogue = new MessageCatalogue($locale);
$this->getContainer()->get('translation.extractor')->extract($bundle->getPath().'/Resources/views', $extractedCatalogue);
$bundlePaths = array(
$bundle->getPath().'/Resources/',
sprintf('%s/Resources/%s/', $kernel->getRootDir(), $bundle->getName()),
);
foreach ($bundlePaths as $path) {
$path = $path.'views';
if (is_dir($path)) {
$this->getContainer()->get('translation.extractor')->extract($path, $extractedCatalogue);
}
}
// Load defined messages
$currentCatalogue = new MessageCatalogue($locale);
if (is_dir($bundle->getPath().'/Resources/translations')) {
$loader->loadMessages($bundle->getPath().'/Resources/translations', $currentCatalogue);
foreach ($bundlePaths as $path) {
$path = $path.'translations';
if (is_dir($path)) {
$loader->loadMessages($path, $currentCatalogue);
}
}
// Merge defined and extracted messages to get all message ids