Skip to content

Commit a36cfd8

Browse 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

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/Symfony/Component/Translation/MessageCatalogue.php

Lines 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];
Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy