Commit 294a39f
committed
bug symfony#58983 [Translation] [Bridge][Lokalise] Fix empty keys array in PUT, DELETE requests causing Lokalise API error (DominicLuidold)
This PR was squashed before being merged into the 5.4 branch.
Discussion
----------
[Translation] [Bridge][Lokalise] Fix empty keys array in PUT, DELETE requests causing Lokalise API error
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | /
| License | MIT
This PR fixes two cases where an empty `keys` array is passed to a `PUT`/`DELETE` request, resulting in a Lokalise API error.
The empty arrays are the result of a `Symfony\Component\Translation\TranslatorBag` containing one or more `Symfony\Component\Translation\MessageCatalogue` _without any_ messages getting passed into the `Symfony\Component\Translation\Bridge\Lokalise\LokaliseProvider` (which is expected behaviour, see [here](https://github.com/symfony/symfony/blob/7.3/src/Symfony/Component/Translation/Command/TranslationPushCommand.php#L153) and below).
This is the case if either
* `bin/console translation:push lokalise`
* `bin/console translation:push lokalise --delete-missing`
is called when both the local translations as well as the translations on Lokalise match 1:1 for a given translation domain.
This will fix the following erros that might be observed while running the mentioned commands:
<details>
<summary>Before/after for <code>translation:push lokalise</code></summary>
**Before:**
```console
$ bin/console translation:push lokalise --domains=validators
ERROR [app] Unable to get keys ids from Lokalise: "{"error":{"message":"`filter_filenames` parameter has invalid values","code":400}}".
[OK] All local translations has been sent to "lokalise" (for "de, en, fr, it" locale(s), and "validators"
domain(s)).
```
**After:**
```console
$ bin/console translation:push lokalise --domains=validators
[OK] All local translations has been sent to "lokalise" (for "de, en, fr, it" locale(s), and "validators"
domain(s)).
```
</details>
<details>
<summary>Before/after for <code>translation:push lokalise --delete-missing</code></summary>
**Before:**
```console
$ bin/console translation:push lokalise --domains=validators --delete-missing
In LokaliseProvider.php line 135:
Unable to delete keys from Lokalise: "{"error":{"message":"`keys` parameter is not valid","code":400}}".
translation:push [--force] [--delete-missing] [--domains [DOMAINS]] [--locales [LOCALES]] [--] [<provider>]
```
**After:**
```console
$ bin/console translation:push lokalise --domains=validators --delete-missing
[OK] Missing translations on "lokalise" has been deleted (for "de, en, fr, it" locale(s), and "validators"
domain(s)).
[OK] All local translations has been sent to "lokalise" (for "de, en, fr, it" locale(s), and "validators"
domain(s)).
```
</details>
Commits
-------
2e51808 [Translation] [Bridge][Lokalise] Fix empty keys array in PUT, DELETE requests causing Lokalise API errorFile tree
2 files changed
+90
-0
lines changed- src/Symfony/Component/Translation/Bridge/Lokalise
- Tests
2 files changed
+90
-0
lines changedLines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| |||
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
264 | 272 | | |
265 | 273 | | |
266 | 274 | | |
| |||
Lines changed: 82 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
252 | 302 | | |
253 | 303 | | |
254 | 304 | | |
| |||
721 | 771 | | |
722 | 772 | | |
723 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
724 | 806 | | |
725 | 807 | | |
726 | 808 | | |
| |||
0 commit comments