i18n-tasks 0.8.7 → 0.9.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -5
  3. data/CHANGES.md +3 -3
  4. data/Gemfile +1 -1
  5. data/README.md +4 -4
  6. data/bin/i18n-tasks +0 -1
  7. data/config/locales/en.yml +103 -102
  8. data/config/locales/ru.yml +1 -1
  9. data/i18n-tasks.gemspec +1 -2
  10. data/lib/i18n/tasks.rb +0 -1
  11. data/lib/i18n/tasks/base_task.rb +0 -1
  12. data/lib/i18n/tasks/cli.rb +1 -1
  13. data/lib/i18n/tasks/command/commander.rb +0 -1
  14. data/lib/i18n/tasks/command/commands/missing.rb +3 -15
  15. data/lib/i18n/tasks/command/commands/usages.rb +5 -6
  16. data/lib/i18n/tasks/command/option_parsers/locale.rb +1 -8
  17. data/lib/i18n/tasks/command_error.rb +5 -1
  18. data/lib/i18n/tasks/commands.rb +0 -1
  19. data/lib/i18n/tasks/configuration.rb +1 -9
  20. data/lib/i18n/tasks/console_context.rb +2 -2
  21. data/lib/i18n/tasks/data.rb +0 -1
  22. data/lib/i18n/tasks/data/adapter/json_adapter.rb +0 -1
  23. data/lib/i18n/tasks/data/adapter/yaml_adapter.rb +0 -1
  24. data/lib/i18n/tasks/data/file_formats.rb +0 -1
  25. data/lib/i18n/tasks/data/file_system.rb +0 -1
  26. data/lib/i18n/tasks/data/file_system_base.rb +0 -1
  27. data/lib/i18n/tasks/data/router/conservative_router.rb +0 -1
  28. data/lib/i18n/tasks/data/router/pattern_router.rb +0 -1
  29. data/lib/i18n/tasks/data/tree/node.rb +6 -7
  30. data/lib/i18n/tasks/data/tree/nodes.rb +0 -1
  31. data/lib/i18n/tasks/data/tree/siblings.rb +29 -10
  32. data/lib/i18n/tasks/data/tree/traversal.rb +0 -3
  33. data/lib/i18n/tasks/google_translation.rb +0 -1
  34. data/lib/i18n/tasks/ignore_keys.rb +0 -1
  35. data/lib/i18n/tasks/key_pattern_matching.rb +0 -1
  36. data/lib/i18n/tasks/logging.rb +0 -1
  37. data/lib/i18n/tasks/missing_keys.rb +0 -1
  38. data/lib/i18n/tasks/plural_keys.rb +0 -1
  39. data/lib/i18n/tasks/reports/base.rb +1 -2
  40. data/lib/i18n/tasks/reports/spreadsheet.rb +0 -1
  41. data/lib/i18n/tasks/reports/terminal.rb +41 -17
  42. data/lib/i18n/tasks/scanners/files/caching_file_finder.rb +32 -0
  43. data/lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb +24 -0
  44. data/lib/i18n/tasks/scanners/files/caching_file_reader.rb +27 -0
  45. data/lib/i18n/tasks/scanners/files/file_finder.rb +61 -0
  46. data/lib/i18n/tasks/scanners/files/file_reader.rb +18 -0
  47. data/lib/i18n/tasks/scanners/key_occurrences.rb +35 -0
  48. data/lib/i18n/tasks/scanners/occurence.rb +50 -0
  49. data/lib/i18n/tasks/scanners/pattern_scanner.rb +97 -38
  50. data/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb +2 -3
  51. data/lib/i18n/tasks/scanners/relative_keys.rb +3 -4
  52. data/lib/i18n/tasks/scanners/scanner.rb +15 -0
  53. data/lib/i18n/tasks/scanners/scanner_multiplexer.rb +43 -0
  54. data/lib/i18n/tasks/unused_keys.rb +4 -5
  55. data/lib/i18n/tasks/used_keys.rb +76 -23
  56. data/lib/i18n/tasks/version.rb +1 -2
  57. data/spec/conservative_router_spec.rb +0 -1
  58. data/spec/file_system_data_spec.rb +0 -1
  59. data/spec/fixtures/app/controllers/events_controller.rb +1 -2
  60. data/spec/google_translate_spec.rb +0 -1
  61. data/spec/i18n_tasks_spec.rb +4 -15
  62. data/spec/key_pattern_matching_spec.rb +0 -1
  63. data/spec/locale_tree/siblings_spec.rb +0 -1
  64. data/spec/pattern_scanner_spec.rb +34 -36
  65. data/spec/plural_keys_spec.rb +0 -1
  66. data/spec/readme_spec.rb +0 -1
  67. data/spec/relative_keys_spec.rb +15 -10
  68. data/spec/scanners/files/caching_file_finder_provider_spec.rb +18 -0
  69. data/spec/scanners/files/caching_file_finder_spec.rb +39 -0
  70. data/spec/scanners/files/caching_file_reader_spec.rb +18 -0
  71. data/spec/scanners/files/file_finder_spec.rb +52 -0
  72. data/spec/scanners/files/file_reader_spec.rb +15 -0
  73. data/spec/scanners/scanner_multiplexer_spec.rb +26 -0
  74. data/spec/spec_helper.rb +1 -1
  75. data/spec/support/capture_std.rb +0 -1
  76. data/spec/support/fixtures.rb +0 -1
  77. data/spec/support/i18n_tasks_output_matcher.rb +0 -1
  78. data/spec/support/key_pattern_matcher.rb +0 -1
  79. data/spec/support/keys_and_occurrences.rb +27 -0
  80. data/spec/support/test_codebase.rb +0 -1
  81. data/spec/support/trees.rb +1 -7
  82. data/spec/used_keys_spec.rb +15 -16
  83. data/templates/config/i18n-tasks.yml +9 -2
  84. metadata +29 -9
  85. data/lib/i18n/tasks/scanners/base_scanner.rb +0 -149
  86. data/spec/commands/missing_commands_spec.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b7283fc75cd948d4e33223d13c310da41c71249
4
- data.tar.gz: a0cbd7255e3306869faec54d994c26659e9c2334
3
+ metadata.gz: 032b4f63664580dc57f296ae0379fc282bdadf26
4
+ data.tar.gz: 217065770a8d92a96b8cf9009ddb7d2dc7dfea30
5
5
  SHA512:
6
- metadata.gz: 50b79a50af3669c354a7c7ebc8acbf6ae6587bb344048b92d89656ab1474b241121ae9794637399ca4a47ec4abe9d383a0b25681aa6c0e26c43e18743c004295
7
- data.tar.gz: ec135b8e1b5638443228fe9d0ec4144876b6e3c8e9fc85cffea9b7c38c1cf6e4d8f79d00c8d9cb2ad2123cfb30a3909bf6ddb6bce186c94f1112e341f043c0bc
6
+ metadata.gz: f20aadc5aa981419c3b6e5641ba3f18c8012d533b54d1e7a7df4490e56b1fe8d60bb2bb8bd7422e61534ac05ec16f3983bd1f360699e1e9dcb4d262ba466b6af
7
+ data.tar.gz: 34f9ab86382cf2ac7c307d4106c2eb470dc270ad97b72a8d4d462d5f5116a7651aa849624623bcbb0a68d48dd25c4775fe113db560395df7196ca44bcc7a88f3
data/.travis.yml CHANGED
@@ -1,13 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
4
- - 1.9.3
5
- - jruby
3
+ - 2.2.2
4
+ - jruby-9000
6
5
  - rbx
7
- # travis uses old bundler (https://travis-ci.org/glebm/i18n-tasks/jobs/53485782)
8
- before_install: gem install bundler
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: rbx
9
9
  cache: bundler
10
10
  script: bundle exec rspec
11
+ sudo: false
11
12
  env:
12
13
  global:
13
14
  - TRAVIS=1
data/CHANGES.md CHANGED
@@ -1,7 +1,7 @@
1
- ## 0.8.7
1
+ ## 0.9.0.rc1
2
2
 
3
- * New interpolation value for `add-missing -v`: `%{key}`. [Stijn Mathysen](https://github.com/stijnster) [#164](https://github.com/glebm/i18n-tasks/pull/164)
4
- * When adding keys from non-default locales, merge base locale first, then the others. [#162](https://github.com/glebm/i18n-tasks/issues/162)
3
+ * Support for multiple scanners.
4
+ * Strict mode enabled by default, can be configured via `search.strict`. New argument: `--no-strict`.
5
5
 
6
6
  ## 0.8.6
7
7
 
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  unless ENV['TRAVIS']
7
7
  group :development do
8
- gem 'byebug', platforms: [:mri_21, :mri_22], require: false
8
+ gem 'byebug', platforms: [:mri_21, :mri_22, :mswin, :x64_mingw_21, :x64_mingw_22], require: false
9
9
  gem 'rubinius-debugger', platform: :rbx, require: false
10
10
  end
11
11
  end
data/README.md CHANGED
@@ -24,7 +24,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
24
24
  Add i18n-tasks to the Gemfile:
25
25
 
26
26
  ```ruby
27
- gem 'i18n-tasks', '~> 0.8.7'
27
+ gem 'i18n-tasks', '~> 0.9.0.rc1'
28
28
  ```
29
29
 
30
30
  Copy the default [configuration file](#configuration):
@@ -72,7 +72,7 @@ $ i18n-tasks add-missing --help
72
72
  Usage: i18n-tasks add-missing [options] [locale ...]
73
73
  -l, --locales Comma-separated list of locale(s) to process. Default: all. Special: base.
74
74
  -f, --format Output format: terminal-table, yaml, json, keys, inspect. Default: terminal-table.
75
- -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}, %{key}. Default: %{value_or_human_key}.
75
+ -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}. Default: %{value_or_human_key}.
76
76
  -h, --help Display this help message.
77
77
  ```
78
78
 
@@ -105,8 +105,8 @@ $ i18n-tasks unused
105
105
  $ i18n-tasks remove-unused
106
106
  ```
107
107
 
108
- These tasks will infer [dynamic keys](#dynamic-keys) such as `t("category.\#{category.name}")` by default.
109
- Pass `-s` or `--strict` to disable this feature.
108
+ These tasks can infer [dynamic keys](#dynamic-keys) such as `t("category.\#{category.name}")` if you set
109
+ `search.strict` to false, or pass `--no-strict` on the command line.
110
110
 
111
111
  ### Normalize data
112
112
 
data/bin/i18n-tasks CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # coding: utf-8
3
2
 
4
3
  # prevent i18n gem warning
5
4
  require 'i18n'
@@ -1,102 +1,103 @@
1
- ---
2
- en:
3
- i18n_tasks:
4
- add_missing:
5
- added:
6
- one: Added %{count} key
7
- other: Added %{count} keys
8
- cmd:
9
- args:
10
- default_text: 'Default: %{value}'
11
- desc:
12
- confirm: Confirm automatically
13
- data_format: 'Data format: %{valid_text}.'
14
- key_pattern: Filter by key pattern (e.g. 'common.*')
15
- key_pattern_to_rename: Full key (pattern) to rename. Required
16
- locale: Locale
17
- locale_to_translate_from: Locale to translate from
18
- locales_filter: 'Locale(s) to process. Special: base'
19
- missing_types: 'Filter by types: %{valid}'
20
- new_key_name: New name, interpolates original name as %{key}. Required
21
- nostdin: Do not read from stdin
22
- out_format: 'Output format: %{valid_text}'
23
- pattern_router: 'Use pattern router: keys moved per config data.write'
24
- strict: Do not infer dynamic key usage such as `t("category.\#{category.name}")`
25
- value: 'Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}, %{key}'
26
- desc:
27
- add_missing: add missing keys to locale data
28
- config: display i18n-tasks configuration
29
- data: show locale data
30
- data_merge: merge locale data with trees
31
- data_remove: remove keys present in tree from data
32
- data_write: replace locale data with tree
33
- eq_base: show translations equal to base value
34
- find: show where keys are used in the code
35
- gem_path: show path to the gem
36
- health: is everything OK?
37
- irb: start REPL session within i18n-tasks context
38
- missing: show missing translations
39
- normalize: 'normalize translation data: sort and move to the right files'
40
- remove_unused: remove unused keys
41
- translate_missing: translate missing keys with Google Translate
42
- tree_convert: convert tree between formats
43
- tree_filter: filter tree by key pattern
44
- tree_merge: merge trees
45
- tree_rename_key: rename tree node
46
- tree_set_value: set values of keys, optionally match a pattern
47
- tree_subtract: tree A minus the keys in tree B
48
- tree_translate: Google Translate a tree to root locales
49
- unused: show unused translations
50
- xlsx_report: save missing and unused translations to an Excel file
51
- encourage:
52
- - Good job!
53
- - Well done!
54
- - Perfect!
55
- enum_list_opt:
56
- invalid: "%{invalid} is not in: %{valid}."
57
- enum_opt:
58
- invalid: "%{invalid} is not one of: %{valid}."
59
- errors:
60
- invalid_format: 'invalid format: %{invalid}. valid: %{valid}.'
61
- invalid_locale: 'invalid locale: %{invalid}'
62
- invalid_missing_type:
63
- one: 'invalid type: %{invalid}. valid: %{valid}.'
64
- other: 'unknown types: %{invalid}. valid: %{valid}.'
65
- pass_forest: pass locale forest
66
- common:
67
- base_value: Base Value
68
- continue_q: Continue?
69
- key: Key
70
- locale: Locale
71
- n_more: "%{count} more"
72
- type: Type
73
- value: Value
74
- data_stats:
75
- text: has %{key_count} keys across %{locale_count} locales. On average, values are %{value_chars_avg}
76
- characters long, keys have %{key_segments_avg} segments, a locale has %{per_locale_avg} keys.
77
- text_single_locale: has %{key_count} keys in total. On average, values are %{value_chars_avg}
78
- characters long, keys have %{key_segments_avg} segments.
79
- title: Forest (%{locales})
80
- google_translate:
81
- errors:
82
- no_api_key: Set Google API key via GOOGLE_TRANSLATE_API_KEY environment variable or translation.api_key
83
- in config/i18n-tasks.yml. Get the key at https://code.google.com/apis/console.
84
- no_results: Google Translate returned no results. Make sure billing information is set at
85
- https://code.google.com/apis/console.
86
- health:
87
- no_keys_detected: No keys detected. Check data.read in config/i18n-tasks.yml.
88
- missing:
89
- details_title: Value in other locales or source
90
- none: No translations are missing.
91
- remove_unused:
92
- confirm:
93
- one: "%{count} translation will be removed from %{locales}."
94
- other: "%{count} translation will be removed from %{locales}."
95
- noop: No unused keys to remove
96
- removed: Removed %{count} keys
97
- translate_missing:
98
- translated: Translated %{count} keys
99
- unused:
100
- none: Every translation is in use.
101
- usages:
102
- none: No key usages found.
1
+ ---
2
+ en:
3
+ i18n_tasks:
4
+ add_missing:
5
+ added:
6
+ one: Added %{count} key
7
+ other: Added %{count} keys
8
+ cmd:
9
+ args:
10
+ default_text: 'Default: %{value}'
11
+ desc:
12
+ confirm: Confirm automatically
13
+ data_format: 'Data format: %{valid_text}.'
14
+ key_pattern: Filter by key pattern (e.g. 'common.*')
15
+ key_pattern_to_rename: Full key (pattern) to rename. Required
16
+ locale: Locale
17
+ locale_to_translate_from: Locale to translate from
18
+ locales_filter: 'Locale(s) to process. Special: base'
19
+ missing_types: 'Filter by types: %{valid}'
20
+ new_key_name: New name, interpolates original name as %{key}. Required
21
+ nostdin: Do not read from stdin
22
+ out_format: 'Output format: %{valid_text}'
23
+ pattern_router: 'Use pattern router: keys moved per config data.write'
24
+ strict: Avoid inferring dynamic key usages such as t("cats.#{cat}.name"). Takes precedence over the
25
+ config setting if set.
26
+ value: 'Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}'
27
+ desc:
28
+ add_missing: add missing keys to locale data
29
+ config: display i18n-tasks configuration
30
+ data: show locale data
31
+ data_merge: merge locale data with trees
32
+ data_remove: remove keys present in tree from data
33
+ data_write: replace locale data with tree
34
+ eq_base: show translations equal to base value
35
+ find: show where keys are used in the code
36
+ gem_path: show path to the gem
37
+ health: is everything OK?
38
+ irb: start REPL session within i18n-tasks context
39
+ missing: show missing translations
40
+ normalize: 'normalize translation data: sort and move to the right files'
41
+ remove_unused: remove unused keys
42
+ translate_missing: translate missing keys with Google Translate
43
+ tree_convert: convert tree between formats
44
+ tree_filter: filter tree by key pattern
45
+ tree_merge: merge trees
46
+ tree_rename_key: rename tree node
47
+ tree_set_value: set values of keys, optionally match a pattern
48
+ tree_subtract: tree A minus the keys in tree B
49
+ tree_translate: Google Translate a tree to root locales
50
+ unused: show unused translations
51
+ xlsx_report: save missing and unused translations to an Excel file
52
+ encourage:
53
+ - Good job!
54
+ - Well done!
55
+ - Perfect!
56
+ enum_list_opt:
57
+ invalid: "%{invalid} is not in: %{valid}."
58
+ enum_opt:
59
+ invalid: "%{invalid} is not one of: %{valid}."
60
+ errors:
61
+ invalid_format: 'invalid format: %{invalid}. valid: %{valid}.'
62
+ invalid_locale: 'invalid locale: %{invalid}'
63
+ invalid_missing_type:
64
+ one: 'invalid type: %{invalid}. valid: %{valid}.'
65
+ other: 'unknown types: %{invalid}. valid: %{valid}.'
66
+ pass_forest: pass locale forest
67
+ common:
68
+ base_value: Base Value
69
+ continue_q: Continue?
70
+ key: Key
71
+ locale: Locale
72
+ n_more: "%{count} more"
73
+ type: Type
74
+ value: Value
75
+ data_stats:
76
+ text: has %{key_count} keys across %{locale_count} locales. On average, values are %{value_chars_avg}
77
+ characters long, keys have %{key_segments_avg} segments, a locale has %{per_locale_avg} keys.
78
+ text_single_locale: has %{key_count} keys in total. On average, values are %{value_chars_avg}
79
+ characters long, keys have %{key_segments_avg} segments.
80
+ title: Forest (%{locales})
81
+ google_translate:
82
+ errors:
83
+ no_api_key: Set Google API key via GOOGLE_TRANSLATE_API_KEY environment variable or translation.api_key
84
+ in config/i18n-tasks.yml. Get the key at https://code.google.com/apis/console.
85
+ no_results: Google Translate returned no results. Make sure billing information is set at
86
+ https://code.google.com/apis/console.
87
+ health:
88
+ no_keys_detected: No keys detected. Check data.read in config/i18n-tasks.yml.
89
+ missing:
90
+ details_title: Value in other locales or source
91
+ none: No translations are missing.
92
+ remove_unused:
93
+ confirm:
94
+ one: "%{count} translation will be removed from %{locales}."
95
+ other: "%{count} translation will be removed from %{locales}."
96
+ noop: No unused keys to remove
97
+ removed: Removed %{count} keys
98
+ translate_missing:
99
+ translated: Translated %{count} keys
100
+ unused:
101
+ none: Every translation is in use.
102
+ usages:
103
+ none: No key usages found.
@@ -21,7 +21,7 @@ ru:
21
21
  out_format: "Формат вывода: %{valid_text}. %{default_text}."
22
22
  pattern_router: "Использовать pattern_router: ключи распределятся по файлам согласно data.write"
23
23
  strict: Не угадывать динамические использования ключей, например `t("category.#{category.key}")`
24
- value: "Значение, интерполируется с %{value}, %{human_key}, %{value_or_human_key}, %{key}"
24
+ value: "Значение, интерполируется с %{value}, %{human_key}, %{value_or_human_key}"
25
25
  desc:
26
26
  add_missing: "добавить недостающие ключи к переводам"
27
27
  config: "показать конфигурацию"
data/i18n-tasks.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'i18n/tasks/version'
@@ -34,7 +33,7 @@ TEXT
34
33
  s.require_paths = ['lib']
35
34
 
36
35
  s.add_dependency 'erubis'
37
- s.add_dependency 'activesupport', '>= 2.3.18'
36
+ s.add_dependency 'activesupport', '>= 4.0.2'
38
37
  s.add_dependency 'easy_translate', '>= 0.5.0'
39
38
  s.add_dependency 'term-ansicolor', '>= 1.3.2'
40
39
  s.add_dependency 'terminal-table', '>= 1.5.1'
data/lib/i18n/tasks.rb CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  # define all the modules to be able to use ::
3
2
  module I18n
4
3
  module Tasks
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  require 'i18n/tasks/command_error'
3
2
  require 'i18n/tasks/split_key'
4
3
  require 'i18n/tasks/key_pattern_matching'
@@ -170,7 +170,7 @@ class I18n::Tasks::CLI
170
170
  end
171
171
 
172
172
  def option_name(flag)
173
- flag.detect { |f| f.start_with?('--') }.sub(/\A--/, '').sub(/[^\-\w].*\z/, '').to_sym
173
+ flag.detect { |f| f.start_with?('--') }.sub(/\A--(\[no-\])?/, '').sub(/[^\-\w].*\z/, '').to_sym
174
174
  end
175
175
 
176
176
  def try_call(v)
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  require 'i18n/tasks/cli'
3
2
  require 'i18n/tasks/reports/terminal'
4
3
  require 'i18n/tasks/reports/spreadsheet'
@@ -47,22 +47,10 @@ module I18n::Tasks
47
47
  args: [:locales, :out_format, arg(:value) + [{default: '%{value_or_human_key}'}]]
48
48
 
49
49
  def add_missing(opt = {})
50
- added = i18n.empty_forest
51
- locales = (opt[:locales] || i18n.locales)
52
- if locales[0] == i18n.base_locale
53
- # Merge base locale first, as this may affect the value for the other locales
54
- forest = i18n.missing_keys({locales: [locales[0]]}.update(opt.slice(:types, :base_locale))).
55
- set_each_value!(opt[:value])
56
- i18n.data.merge! forest
57
- added.merge! forest
58
- locales = locales[1..-1]
59
- end
60
- forest = i18n.missing_keys({locales: locales}.update(opt.slice(:types, :base_locale))).
61
- set_each_value!(opt[:value])
50
+ forest = i18n.missing_keys(opt).set_each_value!(opt[:value])
62
51
  i18n.data.merge! forest
63
- added.merge! forest
64
- log_stderr t('i18n_tasks.add_missing.added', count: added.leaves.count)
65
- print_forest added, opt
52
+ log_stderr t('i18n_tasks.add_missing.added', count: forest.leaves.count)
53
+ print_forest forest, opt
66
54
  end
67
55
  end
68
56
  end
@@ -5,18 +5,17 @@ module I18n::Tasks
5
5
  include Command::Collection
6
6
 
7
7
  arg :strict,
8
- '-s',
9
- '--strict',
8
+ '--[no-]strict',
10
9
  t('i18n_tasks.cmd.args.desc.strict')
11
10
 
12
11
  cmd :find,
13
12
  pos: '[pattern]',
14
13
  desc: t('i18n_tasks.cmd.desc.find'),
15
- args: [:out_format, :pattern]
14
+ args: [:out_format, :pattern, :strict]
16
15
 
17
16
  def find(opt = {})
18
17
  opt[:filter] ||= opt.delete(:pattern) || opt[:arguments].try(:first)
19
- print_forest i18n.used_tree(key_filter: opt[:filter].presence, source_occurrences: true), opt, :used_keys
18
+ print_forest i18n.used_tree(strict: opt[:strict], key_filter: opt[:filter].presence), opt, :used_keys
20
19
  end
21
20
 
22
21
  cmd :unused,
@@ -25,7 +24,7 @@ module I18n::Tasks
25
24
  args: [:locales, :out_format, :strict]
26
25
 
27
26
  def unused(opt = {})
28
- forest = i18n.unused_keys(opt)
27
+ forest = i18n.unused_keys(opt.slice(:locales, :strict))
29
28
  print_forest forest, opt, :unused_keys
30
29
  :exit_1 unless forest.empty?
31
30
  end
@@ -36,7 +35,7 @@ module I18n::Tasks
36
35
  args: [:locales, :out_format, :strict, :confirm]
37
36
 
38
37
  def remove_unused(opt = {})
39
- unused_keys = i18n.unused_keys(opt)
38
+ unused_keys = i18n.unused_keys(opt.slice(:locales, :strict))
40
39
  if unused_keys.present?
41
40
  terminal_report.unused_keys(unused_keys)
42
41
  confirm_remove_unused!(unused_keys, opt)
@@ -36,18 +36,11 @@ module I18n::Tasks
36
36
  if vals == %w(all) || vals.blank?
37
37
  context.locales
38
38
  else
39
- move_base_locale_to_front! vals.map { |v| v == 'base' ? context.base_locale : v }, context.base_locale
39
+ vals.map { |v| v == 'base' ? context.base_locale : v }
40
40
  end.tap do |locales|
41
41
  locales.each { |locale| validate! locale }
42
42
  end
43
43
  end
44
-
45
- def move_base_locale_to_front!(locales, base_locale)
46
- if (pos = locales.index(base_locale)) && pos > 0
47
- locales[pos], locales[0] = locales[0], locales[pos]
48
- end
49
- locales
50
- end
51
44
  end
52
45
  end
53
46
  end
@@ -1,10 +1,14 @@
1
- # coding: utf-8
2
1
  module I18n
3
2
  module Tasks
4
3
  # When this type of error is caught:
5
4
  # 1. show error message of the backtrace
6
5
  # 2. exit with non-zero exit code
7
6
  class CommandError < StandardError
7
+
8
+ def initialize(error = nil, message)
9
+ super(message)
10
+ set_backtrace error.backtrace
11
+ end
8
12
  end
9
13
  end
10
14
  end