8000 [#18637][TranslationDebug] workaround for getFallbackLocales. by aitboudad · Pull Request #20465 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[#18637][TranslationDebug] workaround for getFallbackLocales. #20465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\Translation\LoggingTranslator;

/**
* Helps finding unused or missing translation messages in a given locale
Expand Down Expand Up @@ -157,7 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Load the fallback catalogues
$fallbackCatalogues = array();
$translator = $this->getContainer()->get('translator');
if ($translator instanceof Translator) {
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
if ($fallbackLocale === $locale) {
continue;
Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Translation/DataCollectorTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
return $this->translator->getCatalogue($locale);
}

/**
* Gets the fallback locales.
*
* @return array $locales The fallback locales
*/
public function getFallbackLocales()
{
if ($this->translator instanceof Translator) {
return $this->translator->getFallbackLocales();
}

return array();
}

/**
* Passes through all unknown calls onto the translator object.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Symfony/Component/Translation/LoggingTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public function getCatalogue($locale = null)
return $this->translator->getCatalogue($locale);
}

/**
* Gets the fallback locales.
*
* @return array $locales The fallback locales
*/
public function getFallbackLocales()
{
if ($this->translator instanceof Translator) {
return $this->translator->getFallbackLocales();
}

return array();
}

/**
* Passes through all unknown calls onto the translator object.
*/
Expand Down
0