wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

Stopping sync translation reverts back to synced translation after saving. #607

Open Timusan opened 2 years ago

Timusan commented 2 years ago

As the title implies. When you have a synced translation and you stop it you correctly get the correct "full" edit page for your model. After you hit save the systems reloads the page and reverts back to the synced translations. See attached video.

https://user-images.githubusercontent.com/1012919/187906288-1b9cd83e-e822-4a6d-bde8-285b64e8db4c.mov

pdeero commented 1 year ago

You should try it again with the 1.3.2 version.

Timusan commented 1 year ago

I'm afraid this issue is back since 1.5 release. Exactly same scenario as shown in the video above: Save an async translation and it reverse back to a synced one (without saving any of the filled in fields) with the message "Translation has been restarted". This is on Wagtail 4.2.

This seems to be caused by localize-restart-translation: being present in the POST payload. It has no value (yes or no), just simply is present. Judging from the code this will trigger a synced translation asif the "Start synced translation" button is pressed.

Timusan commented 1 year ago

More specifically, this code in translatable_edit.html:

        {% if translation %}
          <li>
            <form method="POST">
              <input type="hidden" name="localize-restart-translation">
              <button class="button">{% trans "Start Synced translation" %}</button>
            </form>
          </li>
        {% endif %}

If translations are enabled (sync or async), localize-restart-translation will always be shipped with the POST when pressing submit and the input will be added and as such synced translation will be (re)started, even though you just wanted to save an async translation.

Timusan commented 1 year ago

No one else is experiencing thing issue?

zerolab commented 1 year ago

@Timusan unfortunately I am not currently working on any project with translations. It would be great if you could find the time provide a PR with a test or two

Timusan commented 1 year ago

HI @zerolab , that is unfortunate to hear indeed but I fully understand. It is difficult to debug things if you do not have an active project running for this at the moment. I hope Torchbox can find time to further support their localization project.

Well, I have provided both a video demonstrating the exact behaviour (on a vanilla install) and provided the code sample of the template where it goes wrong. I'm unsure what kind of test would be needed or possible to write to reproduce this any further, as this is, on first sight, more of a templating issue than anything else.

However, if time permits I will try to look deeper into the guts of Localize and see if it can be fixed there. Currently, without forking and stripping out this template piece, the project (Localize) is unusable on a fully asynchronously translated site.

zerolab commented 1 year ago

Will try to have a look over the weekend as I understand how frustrating this is.