You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #49833 [Translation] TranslatorBag::diff now iterates over catalogue domains instead of operation domains (welcoMattic)
This PR was merged into the 5.4 branch.
Discussion
----------
[Translation] TranslatorBag::diff now iterates over catalogue domains instead of operation domains
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix#47886 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License | MIT
| Doc PR |
For Loco Provider (at least, but I'm pretty sure it applies for Lokalise and Crowdin), the `--force` option on `translation:push` command has no effect.
The main cause is located in the `TranslatorBag::diff` method which was iterating over `$operation->getDomains()` to add new messages to the diff catalogue. But, the fact is `$operation->getDomains()` returns all domains *AND* their `+intl-icu` variants! Which is certainly not what we want here.
See the test that covers the case
```php
public function testDiffWithIntlDomain()
{
$catalogueA = new MessageCatalogue('en', [
'domain1+intl-icu' => ['foo' => 'foo', 'bar' => 'bar'],
'domain2' => ['baz' => 'baz', 'qux' => 'qux'],
]);
$bagA = new TranslatorBag();
$bagA->addCatalogue($catalogueA);
$catalogueB = new MessageCatalogue('en', [
'domain1' => ['foo' => 'foo'],
'domain2' => ['baz' => 'baz', 'corge' => 'corge'],
]);
$bagB = new TranslatorBag();
$bagB->addCatalogue($catalogueB);
$bagResult = $bagA->diff($bagB);
$this->assertEquals([
'en' => [
'domain1' => ['bar' => 'bar'],
'domain2' => ['qux' => 'qux'],
],
], $this->getAllMessagesFromTranslatorBag($bagResult));
}
```
Without the change, `'foo' => 'foo'` was in the result bag.
Replaces #47986
Commits
-------
178abbf TranslatorBag::diff now iterates over catalogue domains instead of operation domains
Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,52 @@ public function testPushNewMessages()
89
89
$this->assertStringContainsString('[OK] New local translations has been sent to "null" (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
$this->assertStringContainsString('[OK] New local translations has been sent to "null" (for "en, fr" locale(s), and "messages" domain(s)).', trim($tester->getDisplay()));
0 commit comments