diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 5ef264e9..6d374777 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -32,7 +32,7 @@ services: php_translation.importer: public: true class: Translation\Bundle\Service\Importer - arguments: ["@php_translation.extractor", "@twig"] + arguments: ["@php_translation.extractor", "@twig", "%php_translation.default_locale%"] php_translation.cache_clearer: public: true diff --git a/Service/Importer.php b/Service/Importer.php index ad0287a0..1559dadc 100644 --- a/Service/Importer.php +++ b/Service/Importer.php @@ -44,14 +44,21 @@ final class Importer */ private $twig; + /** + * @var string + */ + private $defaultLocale; + /** * @param Extractor $extractor * @param \Twig_Environment $twig + * @param string $defaultLocale */ - public function __construct(Extractor $extractor, \Twig_Environment $twig) + public function __construct(Extractor $extractor, \Twig_Environment $twig, $defaultLocale) { $this->extractor = $extractor; $this->twig = $twig; + $this->defaultLocale = $defaultLocale; } /** @@ -103,7 +110,7 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co $result->set($key, $newTranslation, $domain); // We do not want "translation" key stored anywhere. $meta->removeAllInCategory('translation'); - } elseif (null !== $newTranslation = $meta->getDesc()) { + } elseif (null !== $newTranslation = $meta->getDesc() && $catalogue->getLocale() === $this->defaultLocale) { $result->set($key, $newTranslation, $domain); } }