Skip to content

Commit bd29580

Browse files
committed
TranslatorBag::diff now iterates over catalogue domains instead of operation domains
1 parent 618f920 commit bd29580

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,34 @@ public function testDiff()
6666
], $this->getAllMessagesFromTranslatorBag($bagResult));
6767
}
6868

69+
public function testDiffWithIntlDomain()
70+
{
71+
$catalogueA = new MessageCatalogue('en', [
72+
'domain1+intl-icu' => ['foo' => 'foo', 'bar' => 'bar'],
73+
'domain2' => ['baz' => 'baz', 'qux' => 'qux'],
74+
]);
75+
76+
$bagA = new TranslatorBag();
77+
$bagA->addCatalogue($catalogueA);
78+
79+
$catalogueB = new MessageCatalogue('en', [
80+
'domain1' => ['foo' => 'foo'],
81+
'domain2' => ['baz' => 'baz', 'corge' => 'corge'],
82+
]);
83+
84+
$bagB = new TranslatorBag();
85+
$bagB->addCatalogue($catalogueB);
86+
87+
$bagResult = $bagA->diff($bagB);
88+
89+
$this->assertEquals([
90+
'en' => [
91+
'domain1' => ['bar' => 'bar'],
92+
'domain2' => ['qux' => 'qux'],
93+
],
94+
], $this->getAllMessagesFromTranslatorBag($bagResult));
95+
}
96+
6997
public function testIntersect()
7098
{
7199
$catalogueA = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo', 'bar' => 'bar'], 'domain2' => ['baz' => 'baz', 'qux' => 'qux']]);

src/Symfony/Component/Translation/TranslatorBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function diff(TranslatorBagInterface $diffBag): self
7070
$operation->moveMessagesToIntlDomainsIfPossible(AbstractOperation::NEW_BATCH);
7171
$newCatalogue = new MessageCatalogue($locale);
7272

73-
foreach ($operation->getDomains() as $domain) {
73+
foreach ($catalogue->getDomains() as $domain) {
7474
$newCatalogue->add($operation->getNewMessages($domain), $domain);
7575
}
7676

0 commit comments

Comments
 (0)