Allow translate locales that need to be mapping

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 <35156+javierm@users.noreply.github.com>
This commit is contained in:
taitus
2023-03-09 09:00:41 +01:00
parent c64b49b128
commit 306e7356c3
5 changed files with 42 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ describe Layout::RemoteTranslationsButtonComponent do
let(:component) { Layout::RemoteTranslationsButtonComponent.new(translations) }
before do
allow(RemoteTranslations::Microsoft::AvailableLocales).to receive(:available_locales)
allow(RemoteTranslations::Microsoft::AvailableLocales).to receive(:remote_available_locales)
.and_return(%w[de en es fr pt zh-Hans])
end