Steps to reproduce
- Install the site:
ddev poser ddev symlink-project ddev install - Install config translation:
ddev drush en config_translation - Go to https://babel.ddev.site/admin/config/regional/babel
- Fill "Search" with "Anonymous" and check "Show inactive"
- Press "Filter". You'll get the records containing "anonymous" string (query string is ?langcode=it&translated=all&search=Anonymous&include_inactive=1)
- DON'T reload the page, keep the browser tab open!!!
- In a different tab go to https://babel.ddev.site/admin/config/people/accounts/translate
- Add the Italian translation of the
user.settings:anonymousproperty. - Translate "Anonymous" as "Anonymous IT". Press "Save translation"
- Switch tho the 1st tab but DON'T reload the page!
- Press "Filter".
I'm expecting to see the translation of "Anonymous" as "Anonymous IT" but the field is still empty. Being an Ajax submit, which makes a server roundtrip, I'm expecting the translation field to be updated
BUT, if you reload the page, the translation appears.
This happens also with Locale strings, so it's not related to the used plugin... For instance, search for "Image styles", go to /admin/config/regional/translate and translate the same string, then press "Filter". Will notice the same behavior, and, again, on full page reload it works.
Issue fork babel-3549355
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
claudiu.cristeaComment #5
dxvargas commentedI've made a small change that fixed the issue.
Ready for review.
Comment #6
huzooka@claudiu.cristea As the author of the current form (behavior), my intention was to keep user input between AJAX rounds.
Scenario:
Without the change in this MR, the input at "String B" was kept.
The linked MR changes this behavior, so every time you save / delete a translations, all translation inputs are reloaded with the actual data from DB.
You have to decide if you're fine with this change.
Comment #7
huzookaComment #8
claudiu.cristeaI'm fine because we made now everything faster in #3548484: Improve ::getStrings() performanceEDIT: Sorry, I've misread the above remark. Indeed that's a problem, I didn't test this issue.I think we need both, to keep the input on "Filter" and also to bring updates from outside. In case of conflict the input should win (not 100% sure, but it seems the correct resolution). And we need to test this.
Comment #9
huzooka@dxvargas Can you please check whether it's possible?
Comment #10
huzookaComment #11
dxvargas commentedAnswering to @claudiu.cristea in #8.
If we have a translation in the form input that is different from the storage, how can we decide which one is correct?
To make the distinction between these two possibilities, we would need to keep an hidden input with the original translation.
If this original translation is different from the received translation and different from storage, we know we are in case 1.
If this original translation is the same as the received translation and different from storage, we know we are in case 2.
But I think this is too complex.
I propose an other behavior that I expect that is easier to implement and to understand:
I think this simplifies the process and it's an expected behavior. It complies with the initial plan from @huzooka, explained in #6, and also with the description in the current issue.
Comment #12
dxvargas commentedI'll give it a try with the goal explained by @claudiu.cristea in #8.
Comment #13
dxvargas commentedI've addressed the remarks in #8:
Looking forward for reviews!
Comment #14
dxvargas commentedI need to cover some edge cases. For example, when the original translation was empty.
Comment #15
dxvargas commentedI've tested as much as I could. Added another test. Review please.
Comment #16
huzookaBrilliant, thank you @dxvargas for all your efforts!
Comment #17
huzookaComment #19
huzookaReopening and settings RTBC because the merged HEAD revealed test failures. I will check what's going on locally.
Comment #20
huzookaTo me it seems we have a random error.
Comment #21
huzooka