8000 [TranslationDebug] workaround for getFallbackLocales. · symfony/symfony@31deea1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31deea1

Browse files
committed
[TranslationDebug] workaround for getFallbackLocales.
1 parent 7e53eab commit 31deea1

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Component\Console\Input\InputOption;
2020
use Symfony\Component\Translation\MessageCatalogue;
2121
use Symfony\Component\Translation\Translator;
22+
use Symfony\Component\Translation\DataCollectorTranslator;
23+
use Symfony\Component\Translation\LoggingTranslator;
2224

2325
/**
2426
* Helps finding unused or missing translation messages in a given locale
@@ -157,7 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
157159
// Load the fallback catalogues
158160
$fallbackCatalogues = array();
159161
$translator = $this->getContainer()->get('translator');
160-
if ($translator instanceof Translator) {
162+
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
161163
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
162164
if ($fallbackLocale === $locale) {
163165
continue;

src/Symfony/Component/Translation/DataCollectorTranslator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
8888
return $this->translator->getCatalogue($locale);
8989
}
9090

91+
/**
92+
* Gets the fallback locales.
93+
*
94+
* @return array $locales The fallback locales
95+
*/
96+
public function getFallbackLocales()
97+
{
98+
if ($this->translator instanceof Translator) {
99+
return $this->translator->getFallbackLocales();
100+
}
101+
102+
return array();
103+
}
104+
91105
/**
92106
* Passes through all unknown calls onto the translator object.
93107
*/

src/Symfony/Component/Translation/LoggingTranslator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
8888
return $this->translator->getCatalogue($locale);
8989
}
9090

91+
/**
92+
* Gets the fallback locales.
93+
*
94+
* @return array $locales The fallback locales
95+
*/
96+
public function getFallbackLocales()
97+
{
98+
if ($this->translator instanceof Translator) {
99+
return $this->translator->getFallbackLocales();
100+
}
101+
102+
return array();
103+
}
104+
91105
/**
92106
* Passes through all unknown calls onto the translator object.
93107
*/

0 commit comments

Comments
 (0)
0