i18n-tasks 0.9.31 → 0.9.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -5
  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 +33 -7
  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 +9 -2
  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 +15 -11
  56. data/lib/i18n/tasks/version.rb +1 -1
  57. data/templates/config/i18n-tasks.yml +1 -1
  58. metadata +10 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6f870248df7b94a77747317666b12fa096bd04c6c9a5fc7ab8ef8eb850a207c
4
- data.tar.gz: '092e4392eb447157a40aea73dc0214039dcd31efb09c80d0959750929765620c'
3
+ metadata.gz: 5477cbdf1fb14c575eaad7221cac570147acfcde877fa5960dcdfd958d76d270
4
+ data.tar.gz: b40dbef296c01aa2c047b8ae2f6ef3567f8643b35895516a8fde281f225e6daa
5
5
  SHA512:
6
- metadata.gz: 9756b702d3c268a0fd42f1f203e2c1786903433f0a7492540feeab117de3f6da018fb8d6b41c924414793b050718c71200f3fe801965178212bf13cfdd836960
7
- data.tar.gz: 85328d93b330ea66c77acf856e5d6c549a42e8dc3064487d58b4506a3ff99bb41cc6099cb5e2b44014e863353280f5e012f1d45e1d2e07139c35c4172d200793
6
+ metadata.gz: f732fc9479ba13cd3acb1c7222401f873ace5a8db1ef248712c1ea4dbdb9d05a7fdc5da5bb3600c7c799c64b7f21b1586518b1feec508a0ad36d211110b07b3e
7
+ data.tar.gz: f05241d9bd75bbecb1cb992882d84c4e9826c00c66b66263e7203603e19c9a188e96ea7f4e4131160e23216265df675f4519d190263cf14de59384bd2e62c88d
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # i18n-tasks [![Build Status][badge-travis]][travis] [![Coverage Status][badge-coverage]][coverage] [![Gemnasium][badge-gemnasium]][gemnasium] [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/glebm/i18n-tasks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ # i18n-tasks [![Build Status][badge-travis]][travis] [![Coverage Status][badge-coverage]][coverage] [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/glebm/i18n-tasks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
2
 
3
3
  i18n-tasks helps you find and manage missing and unused translations.
4
4
 
@@ -22,7 +22,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
22
22
  Add i18n-tasks to the Gemfile:
23
23
 
24
24
  ```ruby
25
- gem 'i18n-tasks', '~> 0.9.31'
25
+ gem 'i18n-tasks', '~> 0.9.34'
26
26
  ```
27
27
 
28
28
  Copy the default [configuration file](#configuration):
@@ -385,7 +385,7 @@ See the [config file][config] to find out more.
385
385
  Where this key is depends on your Google API console:
386
386
 
387
387
  * Old console: API Access -> Simple API Access -> Key for server apps.
388
- * New console: Project -> APIS & AUTH -> Credentials -> Public API access -> Key for server applications.
388
+ * New console: Nav Menu -> APIs & Services -> Credentials -> Create Credentials -> API Keys -> Restrict Key -> Cloud Translation API
389
389
 
390
390
  In both cases, you may need to create the key if it doesn't exist.
391
391
 
@@ -437,8 +437,6 @@ Custom tasks can be added easily, see the examples [on the wiki](https://github.
437
437
  [badge-travis]: https://img.shields.io/travis/glebm/i18n-tasks.svg
438
438
  [coverage]: https://codeclimate.com/github/glebm/i18n-tasks
439
439
  [badge-coverage]: https://api.codeclimate.com/v1/badges/5d173e90ada8df07cedc/test_coverage
440
- [gemnasium]: https://gemnasium.com/glebm/i18n-tasks
441
- [badge-gemnasium]: https://gemnasium.com/glebm/i18n-tasks.svg
442
440
  [config]: https://github.com/glebm/i18n-tasks/blob/master/templates/config/i18n-tasks.yml
443
441
  [wiki]: https://github.com/glebm/i18n-tasks/wiki "i18n-tasks wiki"
444
442
  [i18n-gem]: https://github.com/svenfuchs/i18n "svenfuchs/i18n on Github"
data/i18n-tasks.gemspec CHANGED
@@ -16,16 +16,16 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
16
16
 
17
17
  It analyses code statically for key usages, such as `I18n.t('some.key')`, in order to report keys that are missing or unused,
18
18
  pre-fill missing keys (optionally from Google Translate), and remove unused keys.
19
- TEXT
19
+ TEXT
20
20
  s.post_install_message = <<~TEXT
21
21
  # Install default configuration:
22
22
  cp $(bundle exec i18n-tasks gem-path)/templates/config/i18n-tasks.yml config/
23
23
  # Add an RSpec for missing and unused keys:
24
24
  cp $(bundle exec i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/
25
- TEXT
25
+ TEXT
26
26
  s.homepage = 'https://github.com/glebm/i18n-tasks'
27
27
  s.metadata = { 'issue_tracker' => 'https://github.com/glebm/i18n-tasks' } if s.respond_to?(:metadata=)
28
- s.required_ruby_version = '~> 2.3' if s.respond_to?(:required_ruby_version=)
28
+ s.required_ruby_version = '>= 2.5', '< 4.0' if s.respond_to?(:required_ruby_version=)
29
29
 
30
30
  s.files = `git ls-files`.split($/)
31
31
  s.files -= s.files.grep(%r{^(doc/|\.|spec/)}) + %w[CHANGES.md config/i18n-tasks.yml Gemfile]
@@ -46,7 +46,7 @@ TEXT
46
46
  s.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.1'
47
47
  s.add_development_dependency 'rake'
48
48
  s.add_development_dependency 'rspec', '~> 3.3'
49
- s.add_development_dependency 'rubocop', '~> 0.53.0'
49
+ s.add_development_dependency 'rubocop', '~> 1.6.1'
50
50
  s.add_development_dependency 'simplecov'
51
51
  s.add_development_dependency 'yard'
52
52
 
@@ -15,21 +15,19 @@ class I18n::Tasks::CLI
15
15
 
16
16
  def start(argv)
17
17
  auto_output_coloring do
18
+ exit 1 if run(argv) == :exit1
19
+ rescue OptionParser::ParseError => e
20
+ error e.message, 64
21
+ rescue I18n::Tasks::CommandError => e
18
22
  begin
19
- exit 1 if run(argv) == :exit_1
20
- rescue OptionParser::ParseError => e
21
- error e.message, 64
22
- rescue I18n::Tasks::CommandError => e
23
- begin
24
- error e.message, 78
25
- ensure
26
- log_verbose e.backtrace * "\n"
27
- end
28
- rescue Errno::EPIPE
29
- # ignore Errno::EPIPE which is throw when pipe breaks, e.g.:
30
- # i18n-tasks missing | head
31
- exit 1
23
+ error e.message, 78
24
+ ensure
25
+ log_verbose e.backtrace * "\n"
32
26
  end
27
+ rescue Errno::EPIPE
28
+ # ignore Errno::EPIPE which is throw when pipe breaks, e.g.:
29
+ # i18n-tasks missing | head
30
+ exit 1
33
31
  end
34
32
  rescue ExecutionError => e
35
33
  exit e.exit_code
@@ -195,7 +193,7 @@ class I18n::Tasks::CLI
195
193
  end
196
194
  end
197
195
 
198
- def auto_output_coloring(coloring = ENV['I18N_TASKS_COLOR'] || STDOUT.isatty)
196
+ def auto_output_coloring(coloring = ENV['I18N_TASKS_COLOR'] || $stdout.isatty)
199
197
  coloring_was = Rainbow.enabled
200
198
  Rainbow.enabled = coloring
201
199
  yield
@@ -12,7 +12,7 @@ module I18n::Tasks
12
12
  t('i18n_tasks.cmd.args.desc.pattern_router')
13
13
 
14
14
  cmd :normalize,
15
- pos: '[locale ...]',
15
+ pos: '[locale ...]',
16
16
  desc: t('i18n_tasks.cmd.desc.normalize'),
17
17
  args: %i[locales pattern_router]
18
18
 
@@ -29,7 +29,7 @@ module I18n::Tasks
29
29
  def check_normalized(opt)
30
30
  non_normalized = i18n.non_normalized_paths locales: opt[:locales]
31
31
  terminal_report.check_normalized_results(non_normalized)
32
- :exit_1 unless non_normalized.empty?
32
+ :exit1 unless non_normalized.empty?
33
33
  end
34
34
 
35
35
  cmd :mv,
@@ -37,6 +37,7 @@ module I18n::Tasks
37
37
  desc: t('i18n_tasks.cmd.desc.mv')
38
38
  def mv(opt = {})
39
39
  fail CommandError, 'requires FROM_KEY_PATTERN and TO_KEY_PATTERN' if opt[:arguments].size < 2
40
+
40
41
  from_pattern = opt[:arguments].shift
41
42
  to_pattern = opt[:arguments].shift
42
43
  forest = i18n.data_forest
@@ -50,6 +51,7 @@ module I18n::Tasks
50
51
  desc: t('i18n_tasks.cmd.desc.rm')
51
52
  def rm(opt = {})
52
53
  fail CommandError, 'requires KEY_PATTERN' if opt[:arguments].empty?
54
+
53
55
  forest = i18n.data_forest
54
56
  results = opt[:arguments].each_with_object({}) do |key_pattern, h|
55
57
  h.merge! forest.mv_key!(compile_key_pattern(key_pattern), '', root: false)
@@ -59,7 +61,7 @@ module I18n::Tasks
59
61
  end
60
62
 
61
63
  cmd :data,
62
- pos: '[locale ...]',
64
+ pos: '[locale ...]',
63
65
  desc: t('i18n_tasks.cmd.desc.data'),
64
66
  args: %i[locales out_format]
65
67
 
@@ -68,7 +70,7 @@ module I18n::Tasks
68
70
  end
69
71
 
70
72
  cmd :data_merge,
71
- pos: '[tree ...]',
73
+ pos: '[tree ...]',
72
74
  desc: t('i18n_tasks.cmd.desc.data_merge'),
73
75
  args: %i[data_format nostdin]
74
76
 
@@ -79,7 +81,7 @@ module I18n::Tasks
79
81
  end
80
82
 
81
83
  cmd :data_write,
82
- pos: '[tree]',
84
+ pos: '[tree]',
83
85
  desc: t('i18n_tasks.cmd.desc.data_write'),
84
86
  args: %i[data_format nostdin]
85
87
 
@@ -90,7 +92,7 @@ module I18n::Tasks
90
92
  end
91
93
 
92
94
  cmd :data_remove,
93
- pos: '[tree]',
95
+ pos: '[tree]',
94
96
  desc: t('i18n_tasks.cmd.desc.data_remove'),
95
97
  args: %i[data_format nostdin]
96
98
 
@@ -7,14 +7,14 @@ module I18n::Tasks
7
7
  include Command::Collection
8
8
 
9
9
  cmd :eq_base,
10
- pos: '[locale ...]',
10
+ pos: '[locale ...]',
11
11
  desc: t('i18n_tasks.cmd.desc.eq_base'),
12
12
  args: %i[locales out_format]
13
13
 
14
14
  def eq_base(opt = {})
15
15
  forest = i18n.eq_base_keys(opt)
16
16
  print_forest forest, opt, :eq_base_keys
17
- :exit_1 unless forest.empty?
17
+ :exit1 unless forest.empty?
18
18
  end
19
19
  end
20
20
  end
@@ -7,7 +7,7 @@ module I18n::Tasks
7
7
  include Command::Collection
8
8
 
9
9
  cmd :health,
10
- pos: '[locale ...]',
10
+ pos: '[locale ...]',
11
11
  desc: t('i18n_tasks.cmd.desc.health'),
12
12
  args: %i[locales out_format]
13
13
 
@@ -15,13 +15,14 @@ module I18n::Tasks
15
15
  forest = i18n.data_forest(opt[:locales])
16
16
  stats = i18n.forest_stats(forest)
17
17
  fail CommandError, t('i18n_tasks.health.no_keys_detected') if stats[:key_count].zero?
18
+
18
19
  terminal_report.forest_stats forest, stats
19
20
  [
20
21
  missing(**opt),
21
22
  unused(**opt),
22
23
  check_consistent_interpolations(**opt),
23
24
  check_normalized(**opt)
24
- ].detect { |result| result == :exit_1 }
25
+ ].detect { |result| result == :exit1 }
25
26
  end
26
27
  end
27
28
  end
@@ -14,7 +14,7 @@ module I18n::Tasks
14
14
  def check_consistent_interpolations(opt = {})
15
15
  forest = i18n.inconsistent_interpolations(**opt.slice(:locales, :base_locale))
16
16
  print_forest forest, opt, :inconsistent_interpolations
17
- :exit_1 unless forest.empty?
17
+ :exit1 unless forest.empty?
18
18
  end
19
19
  end
20
20
  end
@@ -7,7 +7,7 @@ module I18n::Tasks
7
7
  include Command::Collection
8
8
 
9
9
  cmd :config,
10
- pos: '[section ...]',
10
+ pos: '[section ...]',
11
11
  desc: t('i18n_tasks.cmd.desc.config')
12
12
 
13
13
  def config(opts = {})
@@ -23,18 +23,18 @@ module I18n::Tasks
23
23
  )
24
24
 
25
25
  cmd :missing,
26
- pos: '[locale ...]',
26
+ pos: '[locale ...]',
27
27
  desc: t('i18n_tasks.cmd.desc.missing'),
28
28
  args: %i[locales out_format missing_types]
29
29
 
30
30
  def missing(opt = {})
31
31
  forest = i18n.missing_keys(**opt.slice(:locales, :base_locale, :types))
32
32
  print_forest forest, opt, :missing_keys
33
- :exit_1 unless forest.empty?
33
+ :exit1 unless forest.empty?
34
34
  end
35
35
 
36
36
  cmd :translate_missing,
37
- pos: '[locale ...]',
37
+ pos: '[locale ...]',
38
38
  desc: t('i18n_tasks.cmd.desc.translate_missing'),
39
39
  args: [:locales, :locale_to_translate_from, arg(:out_format).from(1), :translation_backend]
40
40
 
@@ -47,13 +47,14 @@ module I18n::Tasks
47
47
  end
48
48
 
49
49
  cmd :add_missing,
50
- pos: '[locale ...]',
50
+ pos: '[locale ...]',
51
51
  desc: t('i18n_tasks.cmd.desc.add_missing'),
52
52
  args: [:locales, :out_format, arg(:value) + [{ default: '%{value_or_default_or_human_key}' }],
53
53
  ['--nil-value', 'Set value to nil. Takes precedence over the value argument.']]
54
54
 
55
- def add_missing(opt = {}) # rubocop:disable Metrics/AbcSize
56
- [ # Merge base locale first, as this may affect the value for the other locales
55
+ # Merge base locale first, as this may affect the value for the other locales
56
+ def add_missing(opt = {})
57
+ [
57
58
  [i18n.base_locale] & opt[:locales],
58
59
  opt[:locales] - [i18n.base_locale]
59
60
  ].reject(&:empty?).each_with_object(i18n.empty_forest) do |locales, added|
@@ -8,7 +8,7 @@ module I18n::Tasks
8
8
  include I18n::Tasks::KeyPatternMatching
9
9
 
10
10
  cmd :tree_translate,
11
- pos: '[tree (or stdin)]',
11
+ pos: '[tree (or stdin)]',
12
12
  desc: t('i18n_tasks.cmd.desc.tree_translate'),
13
13
  args: [:locale_to_translate_from, arg(:data_format).from(1), :translation_backend]
14
14
 
@@ -18,7 +18,7 @@ module I18n::Tasks
18
18
  end
19
19
 
20
20
  cmd :tree_merge,
21
- pos: '[[tree] [tree] ... (or stdin)]',
21
+ pos: '[[tree] [tree] ... (or stdin)]',
22
22
  desc: t('i18n_tasks.cmd.desc.tree_merge'),
23
23
  args: %i[data_format nostdin]
24
24
 
@@ -27,7 +27,7 @@ module I18n::Tasks
27
27
  end
28
28
 
29
29
  cmd :tree_filter,
30
- pos: '[pattern] [tree (or stdin)]',
30
+ pos: '[pattern] [tree (or stdin)]',
31
31
  desc: t('i18n_tasks.cmd.desc.tree_filter'),
32
32
  args: %i[data_format pattern]
33
33
 
@@ -52,6 +52,7 @@ module I18n::Tasks
52
52
  args: %i[data_format all_locales]
53
53
  def tree_mv(opt = {})
54
54
  fail CommandError, 'requires FROM_KEY_PATTERN and TO_KEY_PATTERN' if opt[:arguments].size < 2
55
+
55
56
  from_pattern = opt[:arguments].shift
56
57
  to_pattern = opt[:arguments].shift
57
58
  forest = forest_pos_or_stdin!(opt)
@@ -60,7 +61,7 @@ module I18n::Tasks
60
61
  end
61
62
 
62
63
  cmd :tree_subtract,
63
- pos: '[[tree] [tree] ... (or stdin)]',
64
+ pos: '[[tree] [tree] ... (or stdin)]',
64
65
  desc: t('i18n_tasks.cmd.desc.tree_subtract'),
65
66
  args: %i[data_format nostdin]
66
67
 
@@ -71,7 +72,7 @@ module I18n::Tasks
71
72
  end
72
73
 
73
74
  cmd :tree_set_value,
74
- pos: '[VALUE] [tree (or stdin)]',
75
+ pos: '[VALUE] [tree (or stdin)]',
75
76
  desc: t('i18n_tasks.cmd.desc.tree_set_value'),
76
77
  args: %i[value data_format nostdin pattern]
77
78
 
@@ -80,12 +81,13 @@ module I18n::Tasks
80
81
  forest = forest_pos_or_stdin!(opt)
81
82
  key_pattern = opt[:pattern]
82
83
  fail CommandError, 'pass value (-v, --value)' if value.blank?
84
+
83
85
  forest.set_each_value!(value, key_pattern)
84
86
  print_forest forest, opt
85
87
  end
86
88
 
87
89
  cmd :tree_convert,
88
- pos: '[tree (or stdin)]',
90
+ pos: '[tree (or stdin)]',
89
91
  desc: t('i18n_tasks.cmd.desc.tree_convert'),
90
92
  args: [arg(:data_format).dup.tap { |a| a[0..1] = ['-f', '--from FORMAT'] },
91
93
  arg(:out_format).dup.tap { |a| a[0..1] = ['-t', '--to FORMAT'] }]
@@ -16,7 +16,7 @@ module I18n::Tasks
16
16
  t('i18n_tasks.cmd.args.desc.keep_order')
17
17
 
18
18
  cmd :find,
19
- pos: '[pattern]',
19
+ pos: '[pattern]',
20
20
  desc: t('i18n_tasks.cmd.desc.find'),
21
21
  args: %i[out_format pattern strict]
22
22
 
@@ -27,18 +27,18 @@ module I18n::Tasks
27
27
  end
28
28
 
29
29
  cmd :unused,
30
- pos: '[locale ...]',
30
+ pos: '[locale ...]',
31
31
  desc: t('i18n_tasks.cmd.desc.unused'),
32
32
  args: %i[locales out_format strict]
33
33
 
34
34
  def unused(opt = {})
35
35
  forest = i18n.unused_keys(**opt.slice(:locales, :strict))
36
36
  print_forest forest, opt, :unused_keys
37
- :exit_1 unless forest.empty?
37
+ :exit1 unless forest.empty?
38
38
  end
39
39
 
40
40
  cmd :remove_unused,
41
- pos: '[locale ...]',
41
+ pos: '[locale ...]',
42
42
  desc: t('i18n_tasks.cmd.desc.remove_unused'),
43
43
  args: %i[locales out_format strict keep_order confirm pattern]
44
44
 
@@ -66,6 +66,7 @@ module I18n::Tasks
66
66
 
67
67
  def confirm_remove_unused!(unused_keys, opt)
68
68
  return if ENV['CONFIRM'] || opt[:confirm]
69
+
69
70
  locales = Rainbow(unused_keys.flat_map { |root| root.key.split('+') }.sort.uniq * ', ').bright
70
71
  msg = [
71
72
  Rainbow(t('i18n_tasks.remove_unused.confirm', count: unused_keys.leaves.count, locales: locales)).red,
@@ -10,8 +10,8 @@ module I18n::Tasks
10
10
  end
11
11
  end
12
12
 
13
- def t(*args)
14
- I18n.t(*args)
13
+ def t(*args, **kwargs)
14
+ I18n.t(*args, **kwargs)
15
15
  end
16
16
 
17
17
  module ClassMethods
@@ -42,8 +42,8 @@ module I18n::Tasks
42
42
  end
43
43
 
44
44
  # late-bound I18n.t for module bodies
45
- def t(*args)
46
- proc { I18n.t(*args) }
45
+ def t(*args, **kwargs)
46
+ proc { I18n.t(*args, **kwargs) }
47
47
  end
48
48
 
49
49
  # if class is a module, merge DSL definitions when it is included
@@ -16,6 +16,7 @@ module I18n::Tasks
16
16
 
17
17
  def call(value, *)
18
18
  return @valid.first unless value.present?
19
+
19
20
  if @valid.include?(value)
20
21
  value
21
22
  else
@@ -37,6 +38,7 @@ module I18n::Tasks
37
38
  def call(values, *)
38
39
  values = Array(values)
39
40
  return @valid if values == %w[all]
41
+
40
42
  invalid = values - @valid
41
43
  if invalid.empty?
42
44
  if values.empty?
@@ -5,12 +5,13 @@ module I18n::Tasks
5
5
  module OptionParsers
6
6
  module Locale
7
7
  module Validator
8
- VALID_LOCALE_RE = /\A\w[\w\-\.]*\z/i
8
+ VALID_LOCALE_RE = /\A\w[\w\-.]*\z/i.freeze
9
9
 
10
10
  def validate!(locale)
11
11
  if VALID_LOCALE_RE !~ locale
12
12
  fail CommandError, I18n.t('i18n_tasks.cmd.errors.invalid_locale', invalid: locale)
13
13
  end
14
+
14
15
  locale
15
16
  end
16
17
  end