Skip to content

Commit eb8f542

Browse files
Alexisnicolas-grekas
authored andcommitted
[translation] Fix update existing key with existing +int-icu domain
1 parent 43e76a7 commit eb8f542

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

MessageCatalogue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function add($messages, $domain = 'messages')
167167
}
168168
$intlDomain = $domain;
169169
$suffixLength = \strlen(self::INTL_DOMAIN_SUFFIX);
170-
if (\strlen($domain) > $suffixLength && false !== strpos($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
170+
if (\strlen($domain) < $suffixLength || false === strpos($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
171171
$intlDomain .= self::INTL_DOMAIN_SUFFIX;
172172
}
173173
foreach ($messages as $id => $message) {

Tests/MessageCatalogueTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testAll()
6969
$this->assertEquals($messages, $catalogue->all());
7070
}
7171

72-
public function testAllIntICU()
72+
public function testAllIntlIcu()
7373
{
7474
$messages = [
7575
'domain1+intl-icu' => ['foo' => 'bar'],
@@ -129,6 +129,16 @@ public function testAdd()
129129
$this->assertEquals('bar', $catalogue->get('foo', 'domain88'));
130130
}
131131

132+
public function testAddIntlIcu()
133+
{
134+
$catalogue = new MessageCatalogue('en', ['domain1+intl-icu' => ['foo' => 'foo']]);
135+
$catalogue->add(['foo1' => 'foo1'], 'domain1');
136+
$catalogue->add(['foo' => 'bar'], 'domain1');
137+
138+
$this->assertSame('bar', $catalogue->get('foo', 'domain1'));
139+
$this->assertSame('foo1', $catalogue->get('foo1', 'domain1'));
140+
}
141+
132142
public function testReplace()
133143
{
134144
$catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo'], 'domain1+intl-icu' => ['bar' => 'bar']]);

0 commit comments

Comments
 (0)