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

Skip to content

Commit 84b48fe

Browse files
committed
[Translation] correctly handle intl domains with TargetOperation
This would cause issues with merging existing intl domains since it was trying to merge with the target instead of the source. This was originally introduced with c71dfb9 The incorrect Test was introduced with b72b7d3
1 parent cac85b3 commit 84b48fe

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/Symfony/Component/Translation/Catalogue/TargetOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function processDomain($domain)
4949
foreach ($this->source->all($domain) as $id => $message) {
5050
if ($this->target->has($id, $domain)) {
5151
$this->messages[$domain]['all'][$id] = $message;
52-
$d = $this->target->defines($id, $intlDomain) ? $intlDomain : $domain;
52+
$d = $this->source->defines($id, $intlDomain) ? $intlDomain : $domain;
5353
$this->result->add([$id => $message], $d);
5454
if (null !== $keyMetadata = $this->source->getMetadata($id, $d)) {
5555
$this->result->setMetadata($id, $keyMetadata, $d);

src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,45 @@ public function testGetResultWithMixedDomains()
7171
{
7272
$this->assertEquals(
7373
new MessageCatalogue('en', [
74-
'messages+intl-icu' => ['a' => 'old_a'],
74+
'messages' => ['a' => 'old_a'],
7575
]),
7676
$this->createOperation(
7777
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]),
7878
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'new_a']])
7979
)->getResult()
8080
);
81+
82+
$this->assertEquals(
83+
new MessageCatalogue('en', [
84+
'messages+intl-icu' => ['a' => 'old_a'],
85+
]),
86+
$this->createOperation(
87+
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'old_a']]),
88+
new MessageCatalogue('en', ['messages' => ['a' => 'new_a']])
89+
)->getResult()
90+
);
91+
92+
$this->assertEquals(
93+
new MessageCatalogue('en', [
94+
'messages+intl-icu' => ['a' => 'old_a'],
95+
'messages' => ['b' => 'new_b'],
96+
]),
97+
$this->createOperation(
98+
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'old_a']]),
99+
new MessageCatalogue('en', ['messages' => ['a' => 'new_a', 'b' => 'new_b']])
100+
)->getResult()
101+
);
102+
103+
$this->assertEquals(
104+
new MessageCatalogue('en', [
105+
'messages' => ['a' => 'old_a'],
106+
'messages+intl-icu' => ['b' => 'new_b'],
107+
]),
108+
$this->createOperation(
109+
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]),
110+
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'new_a', 'b' => 'new_b']])
111+
)->getResult()
112+
);
81113
}
82114

83115
public function testGetResultWithMetadata()

0 commit comments

Comments
 (0)