Skip to content

Commit

Permalink
20321 Fix linter errors
Browse files Browse the repository at this point in the history
Introduced by previous commits, but never tested before

Closes bookingexperts/support#20321
  • Loading branch information
tom-brouwer-bex committed Jul 9, 2024
1 parent e799186 commit 383db5d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/tasks/translators/base_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def parse_value(untranslated, each_translated, opts)
end
end

INTERPOLATION_KEY_RE = /%\{[^\}]+\}|\{\{.*?\}\}|\{%.*?%\}/.freeze
INTERPOLATION_KEY_RE = /%\{[^}]+\}|\{\{.*?\}\}|\{%.*?%\}/.freeze
UNTRANSLATABLE_STRING = 'X__'

# @param [String] value
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/tasks/translators/deepl_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(*)
def translate_values(list, from:, to:, **options)
results = []

if ( glossary = glossary_for(from, to) )
if (glossary = glossary_for(from, to))
options.merge!({ glossary_id: glossary.id })
end

Expand Down Expand Up @@ -102,7 +102,7 @@ def to_deepl_target_locale(locale)
def glossary_for(source, target)
DeepL.glossaries.list.select do |glossary|
glossary.source_lang == source && glossary.target_lang == target
end.sort_by(&:entry_count).last
end.max_by(&:entry_count)
end

def configure_api_key!
Expand Down
13 changes: 9 additions & 4 deletions spec/deepl_translate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
require 'deepl'

RSpec.describe 'DeepL Translation' do
nil_value_test = ['nil-value-key', nil, nil]
nil_value_test = ['nil-value-key', nil, nil]

text_test = [
'key',
"Hello, %{user} O'Neill! How are you? {{ Check out this Liquid tag, it should not be translated }} {% That applies to this Liquid tag as well %}",
"¡Hola, %{user} O'Neill! ¿Qué tal estás? {{ Check out this Liquid tag, it should not be translated }} {% That applies to this Liquid tag as well %}"
"Hello, %{user} O'Neill! How are you? {{ Check out this Liquid tag, it should not be translated }} \
{% That applies to this Liquid tag as well %}",
"¡Hola, %{user} O'Neill! ¿Qué tal estás? {{ Check out this Liquid tag, it should not be translated }} \
{% That applies to this Liquid tag as well %}"
]

html_test_plrl = ['html-key.html.one', '<span>Hello %{count} {{ count }} {% count %}</span>', '<span>Hola %{count} {{ count }} {% count %}</span>']
html_test_plrl = [
'html-key.html.one', '<span>Hello %{count} {{ count }} {% count %}</span>',
'<span>Hola %{count} {{ count }} {% count %}</span>'
]
array_test = ['array-key', ['Hello.', nil, '', 'Goodbye.'], ['Hola.', nil, '', 'Adiós.']]
array_hash_test = ['array-hash-key',
[{ 'hash_key1' => 'How are you?' }, { 'hash_key2' => nil }, { 'hash_key3' => 'Well.' }],
Expand Down
4 changes: 2 additions & 2 deletions spec/interpolations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
TestCodebase.teardown
end

context 'ruby string interpolations' do
context 'when using ruby string interpolations' do
let(:base_keys) { { 'a' => 'hello %{world}', 'b' => 'foo', 'c' => { 'd' => 'hello %{name}' }, 'e' => 'ok' } }
let(:test_keys) { { 'a' => 'hello', 'b' => 'foo %{bar}', 'c' => { 'd' => 'hola %{amigo}' }, 'e' => 'ok' } }

Expand All @@ -40,7 +40,7 @@
end
end

context 'liquid tags' do
context 'when using liquid tags' do
let(:base_keys) do
{
a: 'hello {{ world }}',
Expand Down

0 comments on commit 383db5d

Please sign in to comment.