Skip to content

Machine translation display priority#6385

Merged
mrcasals merged 16 commits intofeat/machine-translationfrom
feat/machine-translation-display-priority
Aug 14, 2020
Merged

Machine translation display priority#6385
mrcasals merged 16 commits intofeat/machine-translationfrom
feat/machine-translation-display-priority

Conversation

@mrcasals
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals commented Aug 6, 2020

🎩 What? Why?

This PR adds a new configuration to organizations: whether to show the machine-translated or the original text first.

Depending on the installation, admins might want to show the translations first, or the original teext first, so we want to make this configurable. This PR does just that.

It also shows a button to toggle translations. This means that if the user is seeing the machine translations, then the button will allow the user to see the original texts, and the other way around.

For the button, I had to introduce a new dependency: RequestStore. This dependency is already a dependency of PaperTrail, so there's not much change here. It is needed to solve one bug: when the user clicks the toggle translations button, we'd usually save this in an instance variable in the controller. But when we use presenters to render the translations, we don't have access to the controller instance variables, and we're never aware of that toggle request. With RequestStore wee can save parameters per request, in a global way, so we can access them from the presenters. I tried different options and considered moving the presenters to some other gem, but it seemed like a lot of work right now. RequestStore ended up being the simplest solution.

This PR is part of the work done at #6127.

📌 Related Issues

📋 Subtasks

  • Add tests
  • Check with comments

📷 Screenshots (optional)

Description

Presenteers weree not properly setting the `current_organization` helper method, but we can access the `resource.organization` anyway, so this commit does that.
We need to use RequestStore because we translate things from inside presenters, which don't have any access to the request status and instance variables. With RequestStore we can store info per request. It's a dependeency of another dependency (PaperTrial), so this commit is just promoting it as a base dependency.
@mrcasals mrcasals self-assigned this Aug 6, 2020
@mrcasals mrcasals marked this pull request as ready for review August 10, 2020 09:23
@mrcasals mrcasals changed the title [WIP] Machine translation display priority Machine translation display priority Aug 10, 2020
@mrcasals
Copy link
Copy Markdown
Contributor Author

@decidim/core can you review this PR, please? It adds a button to toggle the translations (only shown if translations are active) and adds some tests ensuring the whole workflow works as expected.

These tests were actually wrong, but we didn't notice until we changed
the test DB setup
@mrcasals mrcasals requested review from a team and tramuntanal August 10, 2020 10:11
@mrcasals mrcasals merged commit 681a238 into feat/machine-translation Aug 14, 2020
@mrcasals mrcasals deleted the feat/machine-translation-display-priority branch August 14, 2020 07:56
mrcasals added a commit that referenced this pull request Aug 14, 2020
mrcasals added a commit that referenced this pull request Aug 14, 2020
tramuntanal pushed a commit that referenced this pull request Aug 17, 2020
* Base branch

* remove file

* Base branch

* remove file

* Identify translatable resources (#6145)

* Base branch

* remove file

* Require confirmation on exiting a survey mid-answering (#6118)

* Require confirmation on exit

* Add specs

* Use path instead of url

* Fix changelog

* Trigger build

* Fix expected path on test

* Fix method call

* Take textareas and selects into account

* WIP adding concern

* Adding concern in all the models which have translatable fields

* removed :extended_data as translatable field

* WIP adding concern

* Adding concern in all the models which have translatable fields

* Revert "Require confirmation on exiting a survey mid-answering (#6118)"

This reverts commit bdeb933.

* Revert "remove file"

This reverts commit 2565dbb.

* Revert "Base branch"

This reverts commit 2a09cc4.

Co-authored-by: Marc Riera Casals <mrc2407@gmail.com>

* Add Decidim global and organization config for machine translation (#6128)

* Adding setting to organizations table and creating global config

* Adding config accessor to core.rb

* Base branch

* Added a check to display machine translation settings and changed initializer value

* Fixing lint issue in migration file

* Adding test and removing test file

Co-authored-by: decidim-bot <decidim-bot@users.noreply.github.com>
Co-authored-by: anagha <anagha1996@gmail.com>

* Identifying translatable fields in meetings and comments (#6333)

* Base branch

* remove file

* Idenifying translatable fields in meetings and comments

Co-authored-by: Marc Riera Casals <mrc2407@gmail.com>

* Identifying translatable fields for proposals (#6346)

* Add machine translation service (#6179)

Co-authored-by: Marc Riera Casals <mrc2407@gmail.com>
Co-authored-by: Marc Riera <mrc2407@gmail.com>

* Make some fields non-translatable

* Improve spec

* Don't run job if class is not defined

* Improvee method naming

* Machine translation display priority (#6385)

* Add docs on how to enable the integration

* Add docs on how to write a machine translation service

* Improve code strength

* Fix specs

* Fix specs

Co-authored-by: anagha vl <44900292+anaghavl@users.noreply.github.com>
Co-authored-by: decidim-bot <decidim-bot@users.noreply.github.com>
Co-authored-by: anagha <anagha1996@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant