Skip to content
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
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions Service/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}
}
Expand Down