Commit 96b9f0f
committed
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 domainsFile tree
3 files changed
+75
-1
lines changed- src/Symfony/Component/Translation
- Tests
- Command
3 files changed
+75
-1
lines changedLines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
92 | 138 | | |
93 | 139 | | |
94 | 140 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
69 | 97 | | |
70 | 98 | | |
71 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
0 commit comments