Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0b5ebdb

Browse filesBrowse files
committed
Add intl-icu fallback for MessageCatalogue metadata, matching behavior for messages.
1 parent 12b8bc8 commit 0b5ebdb
Copy full SHA for 0b5ebdb

File tree

Expand file treeCollapse file tree

2 files changed

+37
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+37
-0
lines changed

‎src/Symfony/Component/Translation/MessageCatalogue.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/MessageCatalogue.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ public function getMetadata(string $key = '', string $domain = 'messages'): mixe
217217
return $this->metadata;
218218
}
219219

220+
if (isset($this->metadata[$domain.self::INTL_DOMAIN_SUFFIX])) {
221+
if ('' == $key) {
222+
return $this->metadata[$domain.self::INTL_DOMAIN_SUFFIX];
223+
}
224+
225+
if (isset($this->metadata[$domain.self::INTL_DOMAIN_SUFFIX][$key])) {
226+
return $this->metadata[$domain.self::INTL_DOMAIN_SUFFIX][$key];
227+
}
228+
}
229+
220230
if (isset($this->metadata[$domain])) {
221231
if ('' == $key) {
222232
return $this->metadata[$domain];
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Translation\Tests\Catalogue;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Translation\MessageCatalogue;
16+
17+
class MetadataTest extends TestCase
18+
{
19+
public function testIcuMetadataKept()
20+
{
21+
$mc = new MessageCatalogue('en', ['messages' => ['a' => 'new_a']]);
22+
$metadata = ['metadata' => 'value'];
23+
$mc->setMetadata('a', $metadata, 'messages+intl-icu');
24+
$this->assertEquals($metadata, $mc->getMetadata('a', 'messages'));
25+
$this->assertEquals($metadata, $mc->getMetadata('a', 'messages+intl-icu'));
26+
}
27+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.