Skip to content
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

add translation deepl #4

Merged
merged 6 commits into from
Sep 6, 2021
Merged

Conversation

Quentinchampenois
Copy link
Contributor

@Quentinchampenois Quentinchampenois commented Aug 20, 2021

Implement automatic translation using Deepl

@paulinebessoles
Copy link
Contributor

As discussed earlier, we're waiting for an answer from Alexandru to solve the problem about locale not being defined at the content creation.

@Quentinchampenois Quentinchampenois marked this pull request as draft August 26, 2021 15:13
@Quentinchampenois
Copy link
Contributor Author

I have found an issue on my local environment, for now I am not sure that is reproductible in production mode

In file : decidim-core/app/jobs/decidim/machine_translation_resource_job.rb, the text is undefined which generates a 500 internal server error

I have resolved this issue with the following quick fix :

    def resource_field_value(previous_changes, field)
      values = previous_changes[field]
      new_value = values.last
      return new_value[default_locale(@resource)] if new_value.is_a?(Hash) && new_value[default_locale(@resource)].present?
      return new_value[new_value.keys.first] if new_value.is_a?(Hash)
      new_value
    end

@Quentinchampenois
Copy link
Contributor Author

I have found an issue on my local environment, for now I am not sure that is reproductible in production mode

In file : decidim-core/app/jobs/decidim/machine_translation_resource_job.rb, the text is undefined which generates a 500 internal server error

I have resolved this issue with the following quick fix :

    def resource_field_value(previous_changes, field)
      values = previous_changes[field]
      new_value = values.last
      return new_value[default_locale(@resource)] if new_value.is_a?(Hash) && new_value[default_locale(@resource)].present?
      return new_value[new_value.keys.first] if new_value.is_a?(Hash)
      new_value
    end

I just found this fix on the develop, I have backported a part of this fix

@paulinebessoles paulinebessoles marked this pull request as ready for review August 31, 2021 08:00
Copy link
Contributor

@paulinebessoles paulinebessoles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect @Quentinchampenois !

@paulinebessoles
Copy link
Contributor

@Quentinchampenois could you check failing tests?

@Quentinchampenois Quentinchampenois merged commit 9611d03 into develop Sep 6, 2021
@Quentinchampenois Quentinchampenois deleted the feature/deepl_translator branch September 6, 2021 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants