-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Fix translator overlapse #46190
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
Conversation
xavren
commented
Apr 27, 2022
Q | A |
---|---|
Branch? | 4.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #46189 |
License | MIT |
Doc PR | symfony/symfony-docs#... |
0fcdc41
to
5925013
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but this does not make sense to me as MessageCatalog::get() starts with:
if (isset($this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id])) {
return $this->messages[$domain.self::INTL_DOMAIN_SUFFIX][$id];
}
To confirm, I checked out the PR and reverted the patch: tests still pass.
Can you figure out a tests that fails without the patch?
@xavren still up to finish this one? Can you figure out a failing test case? |
@nicolas-grekas sorry for the delay, we had some new priorities and forgot to follow this issue. You are right, this is not the issue, but the bug exists as demonstrated by this https://github.com/xavren/symfony-translator-bug/blob/master/src/Command/TestCommand.php Code $output->writeln($this->translator->trans('test', ['name' => 'World']));
$output->writeln($this->translator->trans('test', ['name' => 'World'], 'messages+intl-icu'));
$output->writeln($this->translator->trans('test', ['name' => 'World'], 'messages')); Result is php bin/console app:test
Hello %name%
Hello %World%
Hello %name% It seems that MessageCatalogue loading messages has an issue but cannot spot it and did not find any tests :/ For the debug, here is the cache file var/cache/dev/translations/catalogue.en.bBuRKVV.php <?php
use Symfony\Component\Translation\MessageCatalogue;
$catalogue = new MessageCatalogue('en', array (
'messages+intl-icu' =>
array (
'test' => 'Hello %name%',
),
));
return $catalogue; |
Well, using |
@xavren The legacy format replaces whatever you pass as key. so to replace |
@stof, the idea was to show mixup catalogue data, we have legacy data in intl-icu domain, that override intl-icu data, formatted by intlFormatter. |
361394e
to
44fd6d0
Compare
you should not have legacy data in your intl-icu catalogue. That should go in the non-suffixed catalogue for that domain. Putting legacy data in the catalogue that is meant to contain ICU format will indeed not work, and that's totally expected. |
Hi @stof and @nicolas-grekas, i modified my PR adding tests that demonstrate the issue (hopefully) public function testIntlDomainOverlapseWithIntlResourceBefore() does not pass, because MessageCatalogue is mixing up legacy / intl domains |
44fd6d0
to
99ca5f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was likely introduced in #35430
I fixed it, all green. Thanks for the test case.
Thank you @xavren. |