Skip to content

[Translation] Metadata is being lost when +intl-icu is used #60523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pontus-mp opened this issue May 23, 2025 · 0 comments
Closed

[Translation] Metadata is being lost when +intl-icu is used #60523

pontus-mp opened this issue May 23, 2025 · 0 comments

Comments

@pontus-mp
Copy link
Contributor

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

@pontus-mp pontus-mp added the Bug label May 23, 2025
fabpot added a commit that referenced this issue May 29, 2025
…etadata (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
@fabpot fabpot closed this as completed May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants