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

Use Bing Translator instead of TranslatorText #5089

Merged
merged 4 commits into from
Mar 15, 2023
Merged

Conversation

taitus
Copy link
Member

@taitus taitus commented Mar 8, 2023

References

Upgrade Ruby to version 3.0.5 #5074

Objectives

  • TranslatorText isn't compatible with Ruby 3, so we need to use a different gem as example Bing Translator gem.
  • Fix remote translations for locales :pt-BR, :zh-CN and :zh-TW
  • It has been detected that there is already support for locale :gl (Galego) and :sq (Shqip). The only locale (of all the locales supported by consul) that is currently not supported by this translator is :val (Valencià).

Notes

This PR involves some changes in the documentation: Update remote translation docs #119

@javierm javierm added this to Reviewing in Consul Democracy Mar 8, 2023
javierm and others added 3 commits March 9, 2023 05:50
We were including it in the Object class, making its methods
available everywhere.
We usually use this approach because methods are easier to override and
stub.
TranslatorText isn't compatible with Ruby 3, so we need to use a
different gem.

The 'translator-text' gem response was an array of one or more objects.
Now with the 'bing_translator' gem the response is an array with one or
several translated texts.

We remove the concept of object in the code. And we also remove the
"create_response" method from the specs since it is no longer necessary
to emulate that object and we can simply use arrays with texts to emulate
the new response.
@javierm javierm moved this from Reviewing to Doing in Consul Democracy Mar 10, 2023
@javierm javierm self-assigned this Mar 10, 2023
@taitus taitus moved this from Doing to Reviewing in Consul Democracy Mar 13, 2023
@javierm javierm moved this from Reviewing to Doing in Consul Democracy Mar 14, 2023
It has been detected that for the :pt-BR, :zh-CN and :zh-TW locales,
the translate button was being displayed, but when requesting the
translation, the remote translation validation failed due to:

'''
validates :locale, inclusion: { in: ->(_) {
     RemoteTranslations::Microsoft::AvailableLocales.available_locales }}
'''

That available_locales method did not contemplate these 3 languages
in the format used by the application.

To solve this problem the api response is mapped to return all
locales in the format expected by the application.

Add remote translation model test to ensure that a remote translation
is valid when its locale is pt-BR.

Co-Authored-By: Javi Martín <[email protected]>
@taitus taitus moved this from Doing to Reviewing in Consul Democracy Mar 15, 2023
Consul Democracy automation moved this from Reviewing to Testing Mar 15, 2023
@taitus taitus merged commit 9bbde19 into master Mar 15, 2023
Consul Democracy automation moved this from Testing to Release 2.0.0 Mar 15, 2023
@taitus taitus deleted the bing-translator branch March 15, 2023 16:50
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.

None yet

2 participants