Description
Symfony version(s) affected
5.3
Description
Following #43967, it seems that the bug is more serious than expected.
I seem to have inadvertently used a deprecated feature of the Loco API. As we were using it in php-translation loco adapter I haven't checked if it was already ok to use it.
The result is that now, we must pass globally unique id for each translation to Loco. The problem is that translation keys are unique by domain in Symfony.
How to reproduce
See #42395 (comment)
Possible Solution
One possible solution is to set id like:
$id = sprintf('%s_%s', $domain, $key);
And at the fetch time, iterate over all received messages, substract $domain . '_'
from the id to set the right key:
$locoCatalogue = $this->loader->load($responseContent, $locale, $domain);
$catalogue = new MessageCatalogue($locale);
foreach ($locoCatalogue->all($domain) as $key => $message) {
if (str_starts_with($key, $domain . '_')) {
$key = str_replace($domain . '_', '', $key);
}
$catalogue->set($key, $message, $domain);
}
$translatorBag->addCatalogue($catalogue);
It could break something like the batch creation of assets (because local keys are not equals to the Loco ids now), but I think we can solve it.
Additional Context
this bug seems to not happen on Loco projects with an asset alias named name
, which is the old and deprecated name of text
parameter. It seems the value of name
is auto generated by Loco with dot notation.