Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f749f5e

Browse files
committed
bug #45839 [Translation] Fix intersect in TranslatorBag (ossinkine)
This PR was merged into the 5.4 branch. Discussion ---------- [Translation] Fix intersect in TranslatorBag | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT Actually `TranslatorBag::intersect` does the same as `TranslatorBag::diff`, you can see this in tests. This PR fixes it. Commits ------- 363b151 Fix intersect in TranslatorBag
2 parents 9b52da1 + 363b151 commit f749f5e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Component/Translation/Tests/TranslatorBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function testIntersect()
8282

8383
$this->assertEquals([
8484
'en' => [
85-
'domain1' => ['bar' => 'bar'],
86-
'domain2' => ['qux' => 'qux'],
85+
'domain1' => ['foo' => 'foo'],
86+
'domain2' => ['baz' => 'baz'],
8787
],
8888
], $this->getAllMessagesFromTranslatorBag($bagResult));
8989
}

src/Symfony/Component/Translation/TranslatorBag.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ public function intersect(TranslatorBagInterface $intersectBag): self
9494
$obsoleteCatalogue = new MessageCatalogue($locale);
9595

9696
foreach ($operation->getDomains() as $domain) {
97-
$obsoleteCatalogue->add($operation->getObsoleteMessages($domain), $domain);
97+
$obsoleteCatalogue->add(
98+
array_diff($operation->getMessages($domain), $operation->getNewMessages($domain)),
99+
$domain
100+
);
98101
}
99102

100103
$diff->addCatalogue($obsoleteCatalogue);

0 commit comments

Comments
 (0)