-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Loco provider fails when pushing for multiple domains #43953
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
Labels
Comments
Friendly ping @welcoMattic |
I'm working on a fix, but it's more complex than I expected, and it could result on breaking BC. I'll open a PR soon with a first version of the fix. |
2 tasks
nicolas-grekas
added a commit
that referenced
this issue
Nov 29, 2021
… method (welcoMattic) This PR was merged into the 5.3 branch. Discussion ---------- [Translation] [Loco] Fix idempotency of LocoProvider write method | Q | A | ------------- | --- | Branch? | 5.3 | 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 #43953 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | This PR fix the exception thrown when we push translations twice, with existing translations on Loco. Explanation of the fix: To translate an "asset" (a translation key in Loco vocabulary), we need its Loco `id`. But Loco does not allow us to retrieve an id from a key. So, we fetch all ids for the current domain. Then, we build a map with `key` as key, and `id` as value. After that, we can intersect the keys of this map and our messages array to get all Loco ids of the currently processed messages. ```php foreach ($catalogue->all() as $domain => $messages) { $keysIdsMap = []; foreach ($this->getAssetsIds($domain) as $id) { $keysIdsMap[$this->retrieveKeyFromId($id, $domain)] = $id; } $ids = array_intersect_key($keysIdsMap, $messages); $this->translateAssets(array_combine(array_values($ids), array_values($messages)), $locale); } ``` Todo: - [x] Make some real tests to be 100% sure there is no BC - [x] Add tests to guarantee the fix Commits ------- 66a3c03 Fix idempot 5A21 ency of LocoProvider write method
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
5.3.6
Description
Given:
When pushing multiple domains to Loco, exception is thrown:
How to reproduce
php bin\console translation:push loco --domains forms --domains messages --domains validators --force
php bin\console translation:push loco --domains forms --domains messages --domains validators --force
Error occurs.
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: