Closed
Description
Symfony version(s) affected
7.2.6
Description
If you fetch messages using MessageCatalogue::all()
from a MessageCatalogue, it automatically merges domain
and domain+intl-icu
messages. However, MessageCatalogue::getMetadata
does NOT do this, causing messages to exist but metadata missing.
This gets more serious as ->getDomains()
returns the plain domains (without +intl-icu), causing metadata being dropped in most things that loops over messages (such as \Symfony\Component\Translation\Bridge\Crowdin\CrowdinProvider
)
How to reproduce
<?php
require_once './vendor/autoload.php';
$catalog = new \Symfony\Component\Translation\MessageCatalogue("en");
$catalog->add(["key" => "The text"], domain: "messages+intl-icu");
$catalog->setMetadata("key", ['notes' => [['content' => "This will disappear"]]], domain: "messages+intl-icu");
foreach ($catalog->getDomains() as $domain) {
foreach ($catalog->all($domain) as $key => $value) {
// Shouldn't be null here!
if($catalog->getMetadata($key, $domain) == null) {
echo "Woe and despair, my metadata is hiding from me!\n";
}
}
}
Possible Solution
No response
Additional Context
No response