Skip to content

Commit 2cc7f45

Browse files
Merge branch '4.4' into 5.2
* 4.4: [travis] use packagist API v2 [translation] Fix update existing key with existing +int-icu domain [Contracts] Fix branch name in README.md links
2 parents 345c129 + eb8f542 commit 2cc7f45

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
@@ -163,7 +163,7 @@ public function add(array $messages, string $domain = 'messages')
163163
}
164164
$intlDomain = $domain;
165165
$suffixLength = \strlen(self::INTL_DOMAIN_SUFFIX);
166-
if (\strlen($domain) > $suffixLength && false !== strpos($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
166+
if (\strlen($domain) < $suffixLength || false === strpos($domain, self::INTL_DOMAIN_SUFFIX, -$suffixLength)) {
167167
$intlDomain .= self::INTL_DOMAIN_SUFFIX;
168168
}
169169
foreach ($messages as $id => $message) {

Tests/MessageCatalogueTest.php

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

61-
public function testAllIntICU()
61+
public function testAllIntlIcu()
6262
{
6363
$messages = [
6464
'domain1+intl-icu' => ['foo' => 'bar'],
@@ -118,6 +118,16 @@ public function testAdd()
118118
$this->assertEquals('bar', $catalogue->get('foo', 'domain88'));
119119
}
120120

121+
public function testAddIntlIcu()
122+
{
123+
$catalogue = new MessageCatalogue('en', ['domain1+intl-icu' => ['foo' => 'foo']]);
124+
$catalogue->add(['foo1' => 'foo1'], 'domain1');
125+
$catalogue->add(['foo' => 'bar'], 'domain1');
126+
127+
$this->assertSame('bar', $catalogue->get('foo', 'domain1'));
128+
$this->assertSame('foo1', $catalogue->get('foo1', 'domain1'));
129+
}
130+
121131
public function testReplace()
122132
{
123133
$catalogue = new MessageCatalogue('en', ['domain1' => ['foo' => 'foo'], 'domain1+intl-icu' => ['bar' => 'bar']]);

0 commit comments

Comments
 (0)