i18n-tasks 0.9.33 → 0.9.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/i18n-tasks.gemspec +4 -4
  4. data/lib/i18n/tasks/cli.rb +12 -14
  5. data/lib/i18n/tasks/command/commands/data.rb +8 -6
  6. data/lib/i18n/tasks/command/commands/eq_base.rb +2 -2
  7. data/lib/i18n/tasks/command/commands/health.rb +3 -2
  8. data/lib/i18n/tasks/command/commands/interpolations.rb +1 -1
  9. data/lib/i18n/tasks/command/commands/meta.rb +1 -1
  10. data/lib/i18n/tasks/command/commands/missing.rb +7 -6
  11. data/lib/i18n/tasks/command/commands/tree.rb +8 -6
  12. data/lib/i18n/tasks/command/commands/usages.rb +5 -4
  13. data/lib/i18n/tasks/command/dsl.rb +4 -4
  14. data/lib/i18n/tasks/command/option_parsers/enum.rb +2 -0
  15. data/lib/i18n/tasks/command/option_parsers/locale.rb +2 -1
  16. data/lib/i18n/tasks/command/options/data.rb +1 -0
  17. data/lib/i18n/tasks/command/options/locales.rb +5 -5
  18. data/lib/i18n/tasks/concurrent/cached_value.rb +2 -0
  19. data/lib/i18n/tasks/configuration.rb +4 -4
  20. data/lib/i18n/tasks/console_context.rb +1 -1
  21. data/lib/i18n/tasks/data/file_formats.rb +2 -0
  22. data/lib/i18n/tasks/data/file_system_base.rb +7 -6
  23. data/lib/i18n/tasks/data/router/conservative_router.rb +2 -1
  24. data/lib/i18n/tasks/data/router/pattern_router.rb +2 -0
  25. data/lib/i18n/tasks/data/tree/node.rb +5 -2
  26. data/lib/i18n/tasks/data/tree/nodes.rb +1 -0
  27. data/lib/i18n/tasks/data/tree/siblings.rb +9 -2
  28. data/lib/i18n/tasks/data/tree/traversal.rb +11 -2
  29. data/lib/i18n/tasks/html_keys.rb +2 -4
  30. data/lib/i18n/tasks/ignore_keys.rb +4 -3
  31. data/lib/i18n/tasks/interpolations.rb +4 -2
  32. data/lib/i18n/tasks/key_pattern_matching.rb +3 -2
  33. data/lib/i18n/tasks/missing_keys.rb +3 -0
  34. data/lib/i18n/tasks/plural_keys.rb +6 -1
  35. data/lib/i18n/tasks/references.rb +2 -0
  36. data/lib/i18n/tasks/reports/base.rb +3 -2
  37. data/lib/i18n/tasks/reports/terminal.rb +6 -4
  38. data/lib/i18n/tasks/scanners/file_scanner.rb +4 -3
  39. data/lib/i18n/tasks/scanners/files/caching_file_finder.rb +0 -3
  40. data/lib/i18n/tasks/scanners/files/file_finder.rb +3 -2
  41. data/lib/i18n/tasks/scanners/occurrence_from_position.rb +3 -3
  42. data/lib/i18n/tasks/scanners/pattern_scanner.rb +7 -4
  43. data/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb +4 -2
  44. data/lib/i18n/tasks/scanners/relative_keys.rb +1 -0
  45. data/lib/i18n/tasks/scanners/ruby_ast_scanner.rb +16 -13
  46. data/lib/i18n/tasks/scanners/ruby_key_literals.rb +3 -3
  47. data/lib/i18n/tasks/scanners/scanner_multiplexer.rb +2 -0
  48. data/lib/i18n/tasks/split_key.rb +2 -0
  49. data/lib/i18n/tasks/string_interpolation.rb +1 -0
  50. data/lib/i18n/tasks/translation.rb +3 -3
  51. data/lib/i18n/tasks/translators/base_translator.rb +3 -1
  52. data/lib/i18n/tasks/translators/deepl_translator.rb +3 -1
  53. data/lib/i18n/tasks/translators/google_translator.rb +2 -0
  54. data/lib/i18n/tasks/translators/yandex_translator.rb +2 -0
  55. data/lib/i18n/tasks/used_keys.rb +13 -10
  56. data/lib/i18n/tasks/version.rb +1 -1
  57. metadata +5 -5
@@ -10,12 +10,14 @@ module I18n::Tasks
10
10
  data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? }))
11
11
  fail ArgumentError, 'usages must be a Data::Tree::Instance' unless usages.is_a?(Data::Tree::Siblings)
12
12
  fail ArgumentError, 'all_references must be a Data::Tree::Instance' unless data_refs.is_a?(Data::Tree::Siblings)
13
+
13
14
  raw_refs = empty_forest
14
15
  resolved_refs = empty_forest
15
16
  refs = empty_forest
16
17
  data_refs.key_to_node.each do |ref_key_part, ref_node|
17
18
  usages.each do |usage_node|
18
19
  next unless usage_node.key == ref_key_part
20
+
19
21
  if ref_node.leaf?
20
22
  process_leaf!(ref_node, usage_node, raw_refs, resolved_refs, refs)
21
23
  else
@@ -9,6 +9,7 @@ module I18n::Tasks::Reports
9
9
  end
10
10
 
11
11
  attr_reader :task
12
+
12
13
  delegate :base_locale, :locales, to: :task
13
14
 
14
15
  protected
@@ -58,6 +59,7 @@ module I18n::Tasks::Reports
58
59
 
59
60
  def format_locale(locale)
60
61
  return '' unless locale
62
+
61
63
  if locale.split('+') == task.locales.sort
62
64
  'all'
63
65
  else
@@ -67,8 +69,7 @@ module I18n::Tasks::Reports
67
69
 
68
70
  def collapse_missing_tree!(forest)
69
71
  forest = task.collapse_plural_nodes!(forest)
70
- forest = task.collapse_same_key_in_locales!(forest) { |node| node.data[:type] == :missing_used }
71
- forest
72
+ task.collapse_same_key_in_locales!(forest) { |node| node.data[:type] == :missing_used }
72
73
  end
73
74
  end
74
75
  end
@@ -106,9 +106,10 @@ module I18n
106
106
  private
107
107
 
108
108
  def missing_key_info(leaf)
109
- if leaf[:type] == :missing_used
109
+ case leaf[:type]
110
+ when :missing_used
110
111
  first_occurrence leaf
111
- elsif leaf[:type] == :missing_plural
112
+ when :missing_plural
112
113
  leaf[:data][:missing_keys].join(', ')
113
114
  else
114
115
  "#{Rainbow(leaf[:data][:missing_diff_locale]).cyan} "\
@@ -134,6 +135,7 @@ module I18n
134
135
 
135
136
  def format_reference_desc(node_data)
136
137
  return nil unless node_data
138
+
137
139
  case node_data[:ref_type]
138
140
  when :reference_usage
139
141
  Rainbow('(ref)').yellow.bright
@@ -159,9 +161,9 @@ module I18n
159
161
  print_table headings: [Rainbow(I18n.t('i18n_tasks.common.locale')).cyan.bright,
160
162
  Rainbow(I18n.t('i18n_tasks.common.key')).cyan.bright,
161
163
  I18n.t('i18n_tasks.common.value')] do |t|
162
- t.rows = locale_key_value_datas.map { |(locale, k, v, data)|
164
+ t.rows = locale_key_value_datas.map do |(locale, k, v, data)|
163
165
  [{ value: Rainbow(locale).cyan, alignment: :center }, format_key(k, data), format_value(v)]
164
- }
166
+ end
165
167
  end
166
168
  else
167
169
  puts 'ø'
@@ -11,10 +11,11 @@ module I18n::Tasks::Scanners
11
11
  attr_reader :config
12
12
 
13
13
  def initialize(
14
- config: {},
15
- file_finder_provider: Files::CachingFileFinderProvider.new,
16
- file_reader: Files::CachingFileReader.new
14
+ config: {},
15
+ file_finder_provider: Files::CachingFileFinderProvider.new,
16
+ file_reader: Files::CachingFileReader.new
17
17
  )
18
+ super()
18
19
  @config = config
19
20
  @file_reader = file_reader
20
21
  @file_finder = file_finder_provider.get(**config.slice(:paths, :only, :exclude))
@@ -22,9 +22,6 @@ module I18n::Tasks::Scanners::Files
22
22
  # @param (see FileFinder#traverse_files)
23
23
  # @yieldparam (see FileFinder#traverse_files)
24
24
  # @return (see FileFinder#traverse_files)
25
- def traverse_files
26
- super
27
- end
28
25
 
29
26
  alias uncached_find_files find_files
30
27
  private :uncached_find_files
@@ -15,6 +15,7 @@ module I18n::Tasks::Scanners::Files
15
15
  # Files matching any of the exclusion patterns will be excluded even if they match an inclusion pattern.
16
16
  def initialize(paths: ['.'], only: nil, exclude: [])
17
17
  fail 'paths argument is required' if paths.nil?
18
+
18
19
  @paths = paths
19
20
  @include = only
20
21
  @exclude = exclude || []
@@ -25,8 +26,8 @@ module I18n::Tasks::Scanners::Files
25
26
  # @yield [path]
26
27
  # @yieldparam path [String] the path of the found file.
27
28
  # @return [Array<of block results>]
28
- def traverse_files
29
- find_files.map { |path| yield path }
29
+ def traverse_files(&block)
30
+ find_files.map(&block)
30
31
  end
31
32
 
32
33
  # @return [Array<String>] found files
@@ -15,11 +15,11 @@ module I18n
15
15
  line_begin = contents.rindex(/^/, position - 1)
16
16
  line_end = contents.index(/.(?=\r?\n|$)/, position)
17
17
  Results::Occurrence.new(
18
- path: path,
19
- pos: position,
18
+ path: path,
19
+ pos: position,
20
20
  line_num: contents[0..position].count("\n") + 1,
21
21
  line_pos: position - line_begin + 1,
22
- line: contents[line_begin..line_end],
22
+ line: contents[line_begin..line_end],
23
23
  raw_key: raw_key
24
24
  )
25
25
  end
@@ -12,7 +12,7 @@ module I18n::Tasks::Scanners
12
12
  include OccurrenceFromPosition
13
13
  include RubyKeyLiterals
14
14
 
15
- TRANSLATE_CALL_RE = /(?<=^|[^\w'\-.]|[^\w'\-]I18n\.|I18n\.)t(?:!|ranslate!?)?/
15
+ TRANSLATE_CALL_RE = /(?<=^|[^\w'\-.]|[^\w'\-]I18n\.|I18n\.)t(?:!|ranslate!?)?/.freeze
16
16
  IGNORE_LINES = {
17
17
  'coffee' => /^\s*#(?!\si18n-tasks-use)/,
18
18
  'erb' => /^\s*<%\s*#(?!\si18n-tasks-use)/,
@@ -43,10 +43,13 @@ module I18n::Tasks::Scanners
43
43
  src_pos = Regexp.last_match.offset(0).first
44
44
  location = occurrence_from_position(path, text, src_pos, raw_key: strip_literal(match[0]))
45
45
  next if exclude_line?(location.line, path)
46
+
46
47
  key = match_to_key(match, path, location)
47
48
  next unless key
49
+
48
50
  key += ':' if key.end_with?('.')
49
51
  next unless valid_key?(key)
52
+
50
53
  keys << [key, location]
51
54
  end
52
55
  keys
@@ -67,7 +70,7 @@ module I18n::Tasks::Scanners
67
70
  re && re =~ line
68
71
  end
69
72
 
70
- VALID_KEY_RE_DYNAMIC = /^(#{VALID_KEY_CHARS}|[:\#{@}\[\]])+$/
73
+ VALID_KEY_RE_DYNAMIC = /^(#{VALID_KEY_CHARS}|[:\#{@}\[\]])+$/.freeze
71
74
 
72
75
  def valid_key?(key)
73
76
  if @config[:strict]
@@ -84,7 +87,7 @@ module I18n::Tasks::Scanners
84
87
  def closest_method(occurrence)
85
88
  method = File.readlines(occurrence.path, encoding: 'UTF-8')
86
89
  .first(occurrence.line_num - 1).reverse_each.find { |x| x =~ /\bdef\b/ }
87
- method && method.strip.sub(/^def\s*/, '').sub(/[\(\s;].*$/, '')
90
+ method && method.strip.sub(/^def\s*/, '').sub(/[(\s;].*$/, '')
88
91
  end
89
92
 
90
93
  # This method only exists for backwards compatibility with monkey-patches and plugins
@@ -93,7 +96,7 @@ module I18n::Tasks::Scanners
93
96
  def default_pattern
94
97
  # capture only the first argument
95
98
  /
96
- #{translate_call_re} [\( ] \s* (?# fn call begin )
99
+ #{translate_call_re} [( ] \s* (?# fn call begin )
97
100
  (#{first_argument_re}) (?# capture the first argument)
98
101
  /x
99
102
  end
@@ -26,6 +26,7 @@ module I18n::Tasks::Scanners
26
26
  if scope
27
27
  scope_parts = extract_literal_or_array_of_literals(scope)
28
28
  return nil if scope_parts.nil? || scope_parts.empty?
29
+
29
30
  "#{scope_parts.join('.')}.#{key}"
30
31
  else
31
32
  key unless match[0] =~ /\A\w/
@@ -61,7 +62,7 @@ module I18n::Tasks::Scanners
61
62
 
62
63
  # extract literal or array of literals
63
64
  # returns nil on any other input
64
- # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
65
+ # rubocop:disable Metrics/MethodLength,Metrics/PerceivedComplexity
65
66
  def extract_literal_or_array_of_literals(s)
66
67
  literals = []
67
68
  braces_stack = []
@@ -78,6 +79,7 @@ module I18n::Tasks::Scanners
78
79
  s.each_char.with_index do |c, i|
79
80
  if c == '['
80
81
  return nil unless braces_stack.empty?
82
+
81
83
  braces_stack.push(i)
82
84
  elsif c == ']'
83
85
  break
@@ -93,6 +95,6 @@ module I18n::Tasks::Scanners
93
95
  consume_literal.call unless acc.empty?
94
96
  literals
95
97
  end
96
- # rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
98
+ # rubocop:enable Metrics/MethodLength,Metrics/PerceivedComplexity
97
99
  end
98
100
  end
@@ -12,6 +12,7 @@ module I18n
12
12
  def absolute_key(key, path, roots: config[:relative_roots], calling_method: nil)
13
13
  return key unless key.start_with?(DOT)
14
14
  fail 'roots argument is required' unless roots.present?
15
+
15
16
  normalized_path = File.expand_path(path)
16
17
  (root = path_root(normalized_path, roots)) ||
17
18
  fail(CommandError, "Cannot resolve relative key \"#{key}\".\n" \
@@ -5,7 +5,7 @@ require 'i18n/tasks/scanners/relative_keys'
5
5
  require 'i18n/tasks/scanners/ruby_ast_call_finder'
6
6
  require 'parser/current'
7
7
 
8
- # rubocop:disable Metrics/AbcSize,Metrics/BlockNesting,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
8
+ # rubocop:disable Metrics/AbcSize,Metrics/BlockNesting,Metrics/PerceivedComplexity
9
9
  # TODO: make this class more readable.
10
10
 
11
11
  module I18n::Tasks::Scanners
@@ -14,7 +14,7 @@ module I18n::Tasks::Scanners
14
14
  include RelativeKeys
15
15
  include AST::Sexp
16
16
 
17
- MAGIC_COMMENT_PREFIX = /\A.\s*i18n-tasks-use\s+/
17
+ MAGIC_COMMENT_PREFIX = /\A.\s*i18n-tasks-use\s+/.freeze
18
18
  RECEIVER_MESSAGES = [nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t t! translate translate!])
19
19
 
20
20
  def initialize(**args)
@@ -71,6 +71,7 @@ module I18n::Tasks::Scanners
71
71
  scope = extract_string(scope_node.children[1],
72
72
  array_join_with: '.', array_flatten: true, array_reject_blank: true)
73
73
  return nil if scope.nil? && scope_node.type != :nil
74
+
74
75
  key = [scope, key].join('.') unless scope == ''
75
76
  end
76
77
  default_arg = if (default_arg_node = extract_hash_pair(second_arg_node, 'default'))
@@ -95,6 +96,7 @@ module I18n::Tasks::Scanners
95
96
  def extract_hash_pair(node, key)
96
97
  node.children.detect do |child|
97
98
  next unless child.type == :pair
99
+
98
100
  key_node = child.children[0]
99
101
  %i[sym str].include?(key_node.type) && key_node.children[0].to_s == key
100
102
  end
@@ -115,15 +117,15 @@ module I18n::Tasks::Scanners
115
117
  def extract_string(node, array_join_with: nil, array_flatten: false, array_reject_blank: false)
116
118
  if %i[sym str int].include?(node.type)
117
119
  node.children[0].to_s
118
- elsif %i[true false].include?(node.type) # rubocop:disable Lint/BooleanSymbol
120
+ elsif %i[true false].include?(node.type)
119
121
  node.type.to_s
120
122
  elsif node.type == :nil
121
123
  ''
122
124
  elsif node.type == :array && array_join_with
123
125
  extract_array_as_string(
124
126
  node,
125
- array_join_with: array_join_with,
126
- array_flatten: array_flatten,
127
+ array_join_with: array_join_with,
128
+ array_flatten: array_flatten,
127
129
  array_reject_blank: array_reject_blank
128
130
  ).tap do |str|
129
131
  # `nil` is returned when a dynamic value is encountered in strict mode. Propagate:
@@ -149,11 +151,12 @@ module I18n::Tasks::Scanners
149
151
  # @return [String, nil] `nil` is returned only when a dynamic value is encountered in strict mode.
150
152
  def extract_array_as_string(node, array_join_with:, array_flatten: false, array_reject_blank: false)
151
153
  children_strings = node.children.map do |child|
152
- if %i[sym str int true false].include?(child.type) # rubocop:disable Lint/BooleanSymbol
154
+ if %i[sym str int true false].include?(child.type)
153
155
  extract_string child
154
156
  else
155
157
  # ignore dynamic argument in strict mode
156
158
  return nil if config[:strict]
159
+
157
160
  if %i[dsym dstr].include?(child.type) || (child.type == :array && array_flatten)
158
161
  extract_string(child, array_join_with: array_join_with)
159
162
  else
@@ -180,12 +183,12 @@ module I18n::Tasks::Scanners
180
183
  # @return [Results::Occurrence]
181
184
  def range_to_occurrence(raw_key, range, default_arg: nil)
182
185
  Results::Occurrence.new(
183
- path: range.source_buffer.name,
184
- pos: range.begin_pos,
185
- line_num: range.line,
186
- line_pos: range.column,
187
- line: range.source_line,
188
- raw_key: raw_key,
186
+ path: range.source_buffer.name,
187
+ pos: range.begin_pos,
188
+ line_num: range.line,
189
+ line_pos: range.column,
190
+ line: range.source_line,
191
+ raw_key: raw_key,
189
192
  default_arg: default_arg
190
193
  )
191
194
  end
@@ -203,4 +206,4 @@ module I18n::Tasks::Scanners
203
206
  end
204
207
  end
205
208
  end
206
- # rubocop:enable Metrics/AbcSize,Metrics/BlockNesting,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
209
+ # rubocop:enable Metrics/AbcSize,Metrics/BlockNesting,Metrics/PerceivedComplexity
@@ -2,7 +2,7 @@
2
2
 
3
3
  module I18n::Tasks::Scanners
4
4
  module RubyKeyLiterals
5
- LITERAL_RE = /:?".+?"|:?'.+?'|:\w+/
5
+ LITERAL_RE = /:?".+?"|:?'.+?'|:\w+/.freeze
6
6
 
7
7
  # Match literals:
8
8
  # * String: '', "#{}"
@@ -20,8 +20,8 @@ module I18n::Tasks::Scanners
20
20
  literal
21
21
  end
22
22
 
23
- VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!:;À-ž])/
24
- VALID_KEY_RE = /^#{VALID_KEY_CHARS}+$/
23
+ VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!:;À-ž])/.freeze
24
+ VALID_KEY_RE = /^#{VALID_KEY_CHARS}+$/.freeze
25
25
 
26
26
  def valid_key?(key)
27
27
  key =~ VALID_KEY_RE && !key.end_with?('.')
@@ -9,6 +9,7 @@ module I18n::Tasks::Scanners
9
9
  class ScannerMultiplexer < Scanner
10
10
  # @param scanners [Array<Scanner>]
11
11
  def initialize(scanners:)
12
+ super()
12
13
  @scanners = scanners
13
14
  end
14
15
 
@@ -25,6 +26,7 @@ module I18n::Tasks::Scanners
25
26
  # @return [Array<Array<Results::KeyOccurrences>>]
26
27
  def collect_results
27
28
  return [@scanners[0].keys] if @scanners.length == 1
29
+
28
30
  Array.new(@scanners.length).tap do |results|
29
31
  results_mutex = Mutex.new
30
32
  @scanners.map.with_index do |scanner, i|
@@ -15,6 +15,7 @@ module I18n
15
15
  parts = []
16
16
  pos = 0
17
17
  return [key] if max == 1
18
+
18
19
  key_parts(key) do |part|
19
20
  parts << part
20
21
  pos += part.length + 1
@@ -36,6 +37,7 @@ module I18n
36
37
  # dots inside braces or parenthesis are not split on
37
38
  def key_parts(key, &block)
38
39
  return enum_for(:key_parts, key) unless block
40
+
39
41
  nesting = PARENS
40
42
  counts = PARENS_ZEROS # dup'd later if key contains parenthesis
41
43
  delim = '.'
@@ -6,6 +6,7 @@ module I18n::Tasks
6
6
 
7
7
  def interpolate_soft(s, t = {})
8
8
  return s unless s
9
+
9
10
  t.each do |k, v|
10
11
  pat = "%{#{k}}"
11
12
  s = s.gsub pat, v.to_s if s.include?(pat)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'i18n/tasks/translators/deepl_translator.rb'
4
- require 'i18n/tasks/translators/google_translator.rb'
5
- require 'i18n/tasks/translators/yandex_translator.rb'
3
+ require 'i18n/tasks/translators/deepl_translator'
4
+ require 'i18n/tasks/translators/google_translator'
5
+ require 'i18n/tasks/translators/yandex_translator'
6
6
 
7
7
  module I18n::Tasks
8
8
  module Translation
@@ -24,6 +24,7 @@ module I18n::Tasks
24
24
  # @return [Array<[String, Object]>] translated list
25
25
  def translate_pairs(list, opts)
26
26
  return [] if list.empty?
27
+
27
28
  opts = opts.dup
28
29
  key_pos = list.each_with_index.inject({}) { |idx, ((k, _v), i)| idx.update(k => i) }
29
30
  # copy reference keys as is, instead of translating
@@ -92,7 +93,7 @@ module I18n::Tasks
92
93
  end
93
94
  end
94
95
 
95
- INTERPOLATION_KEY_RE = /%\{[^}]+}/
96
+ INTERPOLATION_KEY_RE = /%\{[^}]+}/.freeze
96
97
  UNTRANSLATABLE_STRING = 'zxzxzx'
97
98
 
98
99
  # @param [String] value
@@ -110,6 +111,7 @@ module I18n::Tasks
110
111
  # @return [String] 'hello, <round-trippable string>' => 'hello, %{name}'
111
112
  def restore_interpolations(untranslated, translated)
112
113
  return translated if untranslated !~ INTERPOLATION_KEY_RE
114
+
113
115
  values = untranslated.scan(INTERPOLATION_KEY_RE)
114
116
  translated.gsub(/#{Regexp.escape(UNTRANSLATABLE_STRING)}\d+/i) do |m|
115
117
  values[m[UNTRANSLATABLE_STRING.length..-1].to_i]
@@ -48,7 +48,8 @@ module I18n::Tasks::Translators
48
48
  # @return [String] 'hello, <i18n>%{name}</i18n>' => 'hello, %{name}'
49
49
  def restore_interpolations(untranslated, translated)
50
50
  return translated if untranslated !~ INTERPOLATION_KEY_RE
51
- translated.gsub(%r{<\/?i18n>}, '')
51
+
52
+ translated.gsub(%r{</?i18n>}, '')
52
53
  rescue StandardError => e
53
54
  raise_interpolation_error(untranslated, translated, e)
54
55
  end
@@ -67,6 +68,7 @@ module I18n::Tasks::Translators
67
68
  def configure_api_key!
68
69
  api_key = @i18n_tasks.translation_config[:deepl_api_key]
69
70
  fail ::I18n::Tasks::CommandError, I18n.t('i18n_tasks.deepl_translate.errors.no_api_key') if api_key.blank?
71
+
70
72
  DeepL.configure { |config| config.auth_key = api_key }
71
73
  end
72
74
  end
@@ -46,6 +46,7 @@ module I18n::Tasks::Translators
46
46
  # Convert 'es-ES' to 'es'
47
47
  def to_google_translate_compatible_locale(locale)
48
48
  return locale unless locale.include?('-') && !SUPPORTED_LOCALES_WITH_REGION.include?(locale)
49
+
49
50
  locale.split('-', 2).first
50
51
  end
51
52
 
@@ -60,6 +61,7 @@ module I18n::Tasks::Translators
60
61
  key ||= translation_config[:api_key]
61
62
  end
62
63
  fail ::I18n::Tasks::CommandError, I18n.t('i18n_tasks.google_translate.errors.no_api_key') if key.blank?
64
+
63
65
  key
64
66
  end
65
67
  end