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 a36cfd8

Browse filesBrowse files
committed
bug #60549 [Translation] Add intl-icu fallback for MessageCatalogue metadata (pontus-mp)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Translation] Add intl-icu fallback for MessageCatalogue metadata | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #60523 | License | MIT Added domain fallback for metadata, which should match the behavior used for fetching messages. Commits ------- 4ab973c [Translation] Add intl-icu fallback for MessageCatalogue metadata
2 parents b2dd230 + 4ab973c commit a36cfd8
Copy full SHA for a36cfd8

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
@@ -237,6 +237,16 @@ public function getMetadata(string $key = '', string $domain = 'messages'): mixe
237237
return $this->metadata;
238238
}
239239

240+
if (isset($this->metadata[$domain.self::INTL_DOMAIN_SUFFIX])) {
241+
if ('' === $key) {
242+
return $this->metadata[$domain.self::INTL_DOMAIN_SUFFIX];
243+
}
244+
245+
if (isset($this->metadata[$domain.self::INTL_DOMAIN_SUFFIX][$key])) {
246+
return $this->metadata[$domain.self::INTL_DOMAIN_SUFFIX][$key];
247+
}
248+
}
249+
240250
if (isset($this->metadata[$domain])) {
241251
if ('' == $key) {
242252
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 MessageCatalogueTest 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.