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
@@ -43,6 +43,7 @@ module I18n::Tasks::Translators
43
43
  # Convert 'es-ES' to 'es'
44
44
  def to_yandex_compatible_locale(locale)
45
45
  return locale unless locale.include?('-')
46
+
46
47
  locale.split('-', 2).first
47
48
  end
48
49
 
@@ -54,6 +55,7 @@ module I18n::Tasks::Translators
54
55
  @api_key ||= begin
55
56
  key = @i18n_tasks.translation_config[:yandex_api_key]
56
57
  fail ::I18n::Tasks::CommandError, I18n.t('i18n_tasks.yandex_translate.errors.no_api_key') if key.blank?
58
+
57
59
  key
58
60
  end
59
61
  end
@@ -18,8 +18,8 @@ module I18n::Tasks
18
18
  paths: %w[app/].freeze,
19
19
  relative_roots: %w[app/controllers app/helpers app/mailers app/presenters app/views].freeze,
20
20
  scanners: [
21
- ['::I18n::Tasks::Scanners::RubyAstScanner', only: %w[*.rb]],
22
- ['::I18n::Tasks::Scanners::PatternWithScopeScanner', exclude: %w[*.rb]]
21
+ ['::I18n::Tasks::Scanners::RubyAstScanner', { only: %w[*.rb] }],
22
+ ['::I18n::Tasks::Scanners::PatternWithScopeScanner', { exclude: %w[*.rb] }]
23
23
  ],
24
24
  strict: true
25
25
  }.freeze
@@ -56,8 +56,8 @@ module I18n::Tasks
56
56
  keys = keys.select { |k| k.key =~ key_filter_re }
57
57
  end
58
58
  Data::Tree::Node.new(
59
- key: 'used',
60
- data: { key_filter: key_filter },
59
+ key: 'used',
60
+ data: { key_filter: key_filter },
61
61
  children: Data::Tree::Siblings.from_key_occurrences(keys)
62
62
  ).to_siblings
63
63
  end
@@ -73,10 +73,11 @@ module I18n::Tasks
73
73
  if args && args[:strict]
74
74
  fail CommandError, 'the strict option is global and cannot be applied on the scanner level'
75
75
  end
76
+
76
77
  ActiveSupport::Inflector.constantize(class_name).new(
77
- config: merge_scanner_configs(shared_options, args || {}),
78
+ config: merge_scanner_configs(shared_options, args || {}),
78
79
  file_finder_provider: caching_file_finder_provider,
79
- file_reader: caching_file_reader
80
+ file_reader: caching_file_reader
80
81
  )
81
82
  end.tap { |scanners| log_verbose { scanners.map { |s| " #{s.class.name} #{s.config.inspect}" } * "\n" } }
82
83
  )
@@ -124,7 +125,7 @@ module I18n::Tasks
124
125
 
125
126
  # @return [Boolean] whether the key is potentially used in a code expression such as `t("category.#{category_key}")`
126
127
  def used_in_expr?(key)
127
- !!(key =~ expr_key_re) # rubocop:disable Style/DoubleNegation
128
+ !!(key =~ expr_key_re)
128
129
  end
129
130
 
130
131
  private
@@ -140,12 +141,13 @@ module I18n::Tasks
140
141
  def expr_key_re(replacement: ':')
141
142
  @expr_key_re ||= begin
142
143
  # disallow patterns with no keys
143
- ignore_pattern_re = /\A[\.#{replacement}]*\z/
144
+ ignore_pattern_re = /\A[.#{replacement}]*\z/
144
145
  patterns = used_in_source_tree(strict: false).key_names.select do |k|
145
146
  k.end_with?('.') || k =~ /\#{/
146
147
  end.map do |k|
147
148
  pattern = "#{replace_key_exp(k, replacement)}#{replacement if k.end_with?('.')}"
148
149
  next if pattern =~ ignore_pattern_re
150
+
149
151
  pattern
150
152
  end.compact
151
153
  compile_key_pattern "{#{patterns * ','}}"
@@ -161,10 +163,11 @@ module I18n::Tasks
161
163
  braces = []
162
164
  result = []
163
165
  while (match_until = scanner.scan_until(/(?:#?\{|})/))
164
- if scanner.matched == '#{'
166
+ case scanner.matched
167
+ when '#{'
165
168
  braces << scanner.matched
166
169
  result << match_until[0..-3] if braces.length == 1
167
- elsif scanner.matched == '}'
170
+ when '}'
168
171
  prev_brace = braces.pop
169
172
  result << replacement if braces.empty? && prev_brace == '#{'
170
173
  else
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Tasks
5
- VERSION = '0.9.33'
5
+ VERSION = '0.9.34'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.33
4
+ version: 0.9.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-21 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -210,14 +210,14 @@ dependencies:
210
210
  requirements:
211
211
  - - "~>"
212
212
  - !ruby/object:Gem::Version
213
- version: 0.53.0
213
+ version: 1.6.1
214
214
  type: :development
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
217
217
  requirements:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
- version: 0.53.0
220
+ version: 1.6.1
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: simplecov
223
223
  requirement: !ruby/object:Gem::Requirement
@@ -406,7 +406,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
406
406
  requirements:
407
407
  - - ">="
408
408
  - !ruby/object:Gem::Version
409
- version: '2.3'
409
+ version: '2.5'
410
410
  - - "<"
411
411
  - !ruby/object:Gem::Version
412
412
  version: '4.0'