-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] correctly handle intl domains with TargetOperation #42361
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,13 +71,45 @@ public function testGetResultWithMixedDomains() | |
{ | ||
$this->assertEquals( | ||
new MessageCatalogue('en', [ | ||
'messages+intl-icu' => ['a' => 'old_a'], | ||
'messages' => ['a' => 'old_a'], | ||
]), | ||
$this->createOperation( | ||
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]), | ||
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'new_a']]) | ||
)->getResult() | ||
); | ||
|
||
$this->assertEquals( | ||
new MessageCatalogue('en', [ | ||
'messages+intl-icu' => ['a' => 'old_a'], | ||
]), | ||
$this->createOperation( | ||
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'old_a']]), | ||
new MessageCatalogue('en', ['messages' => ['a' => 'new_a']]) | ||
)->getResult() | ||
); | ||
|
||
$this->assertEquals( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is testing the behavior when merging with new messages and mixed domains. Should this be moved into a separate function/test case? Or is it OK to have it all in the same function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer a data provider with some explanations for each data, but this is only a recommendation. |
||
new MessageCatalogue('en', [ | ||
'messages+intl-icu' => ['a' => 'old_a'], | ||
'messages' => ['b' => 'new_b'], | ||
]), | ||
$this->createOperation( | ||
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'old_a']]), | ||
new MessageCatalogue('en', ['messages' => ['a' => 'new_a', 'b' => 'new_b']]) | ||
)->getResult() | ||
); | ||
|
||
$this->assertEquals( | ||
new MessageCatalogue('en', [ | ||
'messages' => ['a' => 'old_a'], | ||
'messages+intl-icu' => ['b' => 'new_b'], | ||
]), | ||
$this->createOperation( | ||
new MessageCatalogue('en', ['messages' => ['a' => 'old_a']]), | ||
new MessageCatalogue('en', ['messages+intl-icu' => ['a' => 'new_a', 'b' => 'new_b']]) | ||
)->getResult() | ||
); | ||
} | ||
|
||
public function testGetResultWithMetadata() | ||
|
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.
Since this is fixing the broken test by saying the test was wrong I now really need someone with a deep understanding of the code to look into this 🙈
But my reasoning for why this is actually the correct and intended behavior was:
Existing messages should always stay in their current domain. Moving new messages to the intl-icu domain is (at least in recent versions) handled by
AbstractOperation::moveMessagesToIntlDomainsIfPossible()
, seesymfony/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
Line 247 in 1629b59
symfony/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php
Lines 157 to 183 in 1629b59
This Test was introduced in b72b7d3 which also should only have affected new messages. So was in my interpretation already wrong at that point.