Skip to content

Commit 359b8cd

Browse files
authored
Only add value from @desc if catalogue has the default locale (#243)
1 parent c9c04e1 commit 359b8cd

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
php_translation.importer:
3333
public: true
3434
class: Translation\Bundle\Service\Importer
35-
arguments: ["@php_translation.extractor", "@twig"]
35+
arguments: ["@php_translation.extractor", "@twig", "%php_translation.default_locale%"]
3636

3737
php_translation.cache_clearer:
3838
public: true

Service/Importer.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,21 @@ final class Importer
4444
*/
4545
private $twig;
4646

47+
/**
48+
* @var string
49+
*/
50+
private $defaultLocale;
51+
4752
/**
4853
* @param Extractor $extractor
4954
* @param \Twig_Environment $twig
55+
* @param string $defaultLocale
5056
*/
51-
public function __construct(Extractor $extractor, \Twig_Environment $twig)
57+
public function __construct(Extractor $extractor, \Twig_Environment $twig, $defaultLocale)
5258
{
5359
$this->extractor = $extractor;
5460
$this->twig = $twig;
61+
$this->defaultLocale = $defaultLocale;
5562
}
5663

5764
/**
@@ -103,7 +110,7 @@ public function extractToCatalogues(Finder $finder, array $catalogues, array $co
103110
$result->set($key, $newTranslation, $domain);
104111
// We do not want "translation" key stored anywhere.
105112
$meta->removeAllInCategory('translation');
106-
} elseif (null !== $newTranslation = $meta->getDesc()) {
113+
} elseif (null !== $newTranslation = $meta->getDesc() && $catalogue->getLocale() === $this->defaultLocale) {
107114
$result->set($key, $newTranslation, $domain);
108115
}
109116
}

0 commit comments

Comments
 (0)