Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@xavren
Copy link
Contributor

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#46189
LicenseMIT
Doc PRsymfony/symfony-docs#...

@carsonbotcarsonbot added this to the4.4 milestoneApr 27, 2022
@carsonbotcarsonbot changed the title[Translator] Fix translator overlapse[Translation] Fix translator overlapseApr 27, 2022
@xavrenxavrenforce-pushed thefix-translator-overlapse branch from0fcdc41 to5925013CompareApril 27, 2022 15:29
Copy link
Member

@nicolas-grekasnicolas-grekas left a 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?

@nicolas-grekas
Copy link
Member

@xavren still up to finish this one? Can you figure out a failing test case?

@xavren
Copy link
ContributorAuthor

@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 thishttps://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:testHello %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

<?phpuseSymfony\Component\Translation\MessageCatalogue;$catalogue =newMessageCatalogue('en',array ('messages+intl-icu' =>array ('test' =>'Hello %name%',  ),));return$catalogue;

@stof
Copy link
Member

Well, using%name% in a catalogue that has the intl suffix is not replaced at all and this is expected, as this is not a placeholder at all in the ICU message format.

@xavren
Copy link
ContributorAuthor

Completly ok with that, but you can see the content of my translations files
image

Result is completly mixed up

@stof
Copy link
Member

@xavren The legacy format replaces whatever you pass as key. so to replace%name%, you need to pass%name% as key, notname (as part if the Intl ICU message format migration,% are trimmed from the placeholder name, but they are notadded automatically)

@xavren
Copy link
ContributorAuthor

@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.
If you tell me this is what's expected, i'll close this issue

@xavrenxavrenforce-pushed thefix-translator-overlapse branch 2 times, most recently from361394e to44fd6d0CompareJune 21, 2022 09:24
@stof
Copy link
Member

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.

@xavren
Copy link
ContributorAuthor

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

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

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.

@nicolas-grekas
Copy link
Member

Thank you@xavren.

@nicolas-grekasnicolas-grekas merged commit23c6b9d intosymfony:4.4Aug 2, 2022
This was referencedAug 26, 2022
@fabpotfabpot mentioned this pull requestAug 26, 2022
@fabpotfabpot mentioned this pull requestSep 30, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

4 participants

@xavren@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp