i18n-tasks 0.9.29 → 0.9.30
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i18n/tasks/command/commander.rb +1 -1
- data/lib/i18n/tasks/command/commands/health.rb +4 -4
- data/lib/i18n/tasks/command/commands/interpolations.rb +1 -1
- data/lib/i18n/tasks/command/commands/missing.rb +1 -1
- data/lib/i18n/tasks/command/commands/usages.rb +2 -2
- data/lib/i18n/tasks/data/tree/node.rb +2 -3
- data/lib/i18n/tasks/data/tree/nodes.rb +1 -2
- data/lib/i18n/tasks/data/tree/siblings.rb +1 -1
- data/lib/i18n/tasks/data/tree/traversal.rb +6 -8
- data/lib/i18n/tasks/reports/terminal.rb +4 -5
- data/lib/i18n/tasks/scanners/pattern_scanner.rb +1 -1
- data/lib/i18n/tasks/scanners/ruby_ast_scanner.rb +2 -2
- data/lib/i18n/tasks/version.rb +1 -1
- data/templates/rspec/i18n_spec.rb +9 -2
- metadata +3 -4
- data/lib/i18n/tasks/rainbow_utils.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c748cb31dcf9a41f13b85f43f0dcad3be53f39ddcff325d41c587c1b32b7812b
|
4
|
+
data.tar.gz: bb8f185177f4c0bdd936c45e71827088d12f45a43718d4a3cf1b533ac937343f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d977df364cc0494ea55b19d45a3754503211433a983b4963f17b0617182752d15651b3c636808399d00fadfbbc4bff3aa2098ef398a50e814fdfd9d30488ff
|
7
|
+
data.tar.gz: e000d084559176d27f3c1ea6938715e076f6b233d767f3c2ed328ecfe07d2c0deb11feefff4ec10cbc2aad51e807fa4ff883aedd694b41dfd3dbd8aabfc2fe2a
|
data/README.md
CHANGED
@@ -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.
|
25
|
+
gem 'i18n-tasks', '~> 0.9.30'
|
26
26
|
```
|
27
27
|
|
28
28
|
Copy the default [configuration file](#configuration):
|
@@ -17,10 +17,10 @@ module I18n::Tasks
|
|
17
17
|
fail CommandError, t('i18n_tasks.health.no_keys_detected') if stats[:key_count].zero?
|
18
18
|
terminal_report.forest_stats forest, stats
|
19
19
|
[
|
20
|
-
missing(opt),
|
21
|
-
unused(opt),
|
22
|
-
check_consistent_interpolations(opt),
|
23
|
-
check_normalized(opt)
|
20
|
+
missing(**opt),
|
21
|
+
unused(**opt),
|
22
|
+
check_consistent_interpolations(**opt),
|
23
|
+
check_normalized(**opt)
|
24
24
|
].detect { |result| result == :exit_1 }
|
25
25
|
end
|
26
26
|
end
|
@@ -12,7 +12,7 @@ module I18n::Tasks
|
|
12
12
|
args: %i[locales out_format]
|
13
13
|
|
14
14
|
def check_consistent_interpolations(opt = {})
|
15
|
-
forest = i18n.inconsistent_interpolations(opt.slice(:locales, :base_locale))
|
15
|
+
forest = i18n.inconsistent_interpolations(**opt.slice(:locales, :base_locale))
|
16
16
|
print_forest forest, opt, :inconsistent_interpolations
|
17
17
|
:exit_1 unless forest.empty?
|
18
18
|
end
|
@@ -28,7 +28,7 @@ module I18n::Tasks
|
|
28
28
|
args: %i[locales out_format missing_types]
|
29
29
|
|
30
30
|
def missing(opt = {})
|
31
|
-
forest = i18n.missing_keys(opt.slice(:locales, :base_locale, :types))
|
31
|
+
forest = i18n.missing_keys(**opt.slice(:locales, :base_locale, :types))
|
32
32
|
print_forest forest, opt, :missing_keys
|
33
33
|
:exit_1 unless forest.empty?
|
34
34
|
end
|
@@ -32,7 +32,7 @@ module I18n::Tasks
|
|
32
32
|
args: %i[locales out_format strict]
|
33
33
|
|
34
34
|
def unused(opt = {})
|
35
|
-
forest = i18n.unused_keys(opt.slice(:locales, :strict))
|
35
|
+
forest = i18n.unused_keys(**opt.slice(:locales, :strict))
|
36
36
|
print_forest forest, opt, :unused_keys
|
37
37
|
:exit_1 unless forest.empty?
|
38
38
|
end
|
@@ -43,7 +43,7 @@ module I18n::Tasks
|
|
43
43
|
args: %i[locales out_format strict keep_order confirm pattern]
|
44
44
|
|
45
45
|
def remove_unused(opt = {}) # rubocop:disable Metrics/AbcSize
|
46
|
-
unused_keys = i18n.unused_keys(opt.slice(:locales, :strict))
|
46
|
+
unused_keys = i18n.unused_keys(**opt.slice(:locales, :strict))
|
47
47
|
|
48
48
|
if opt[:pattern]
|
49
49
|
pattern_re = i18n.compile_key_pattern(opt[:pattern])
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'i18n/tasks/data/tree/traversal'
|
4
4
|
require 'i18n/tasks/data/tree/siblings'
|
5
|
-
require 'i18n/tasks/rainbow_utils'
|
6
5
|
module I18n::Tasks::Data::Tree
|
7
6
|
class Node # rubocop:disable Metrics/ClassLength
|
8
7
|
include Enumerable
|
@@ -28,7 +27,7 @@ module I18n::Tasks::Data::Tree
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def derive(new_attr = {})
|
31
|
-
self.class.new(attributes.merge(new_attr))
|
30
|
+
self.class.new(**attributes.merge(new_attr))
|
32
31
|
end
|
33
32
|
|
34
33
|
def children=(children)
|
@@ -164,7 +163,7 @@ module I18n::Tasks::Data::Tree
|
|
164
163
|
|
165
164
|
def inspect(level = 0)
|
166
165
|
label = if key.nil?
|
167
|
-
|
166
|
+
Rainbow('∅').faint
|
168
167
|
else
|
169
168
|
[Rainbow(key).color(1 + level % 15),
|
170
169
|
(": #{format_value_for_inspect(value)}" if leaf?),
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'i18n/tasks/data/tree/traversal'
|
4
|
-
require 'i18n/tasks/rainbow_utils'
|
5
4
|
module I18n::Tasks::Data::Tree
|
6
5
|
# A list of nodes
|
7
6
|
class Nodes
|
@@ -48,7 +47,7 @@ module I18n::Tasks::Data::Tree
|
|
48
47
|
if present?
|
49
48
|
map(&:inspect) * "\n"
|
50
49
|
else
|
51
|
-
|
50
|
+
Rainbow('{∅}').faint
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
@@ -273,7 +273,7 @@ module I18n::Tasks::Data::Tree
|
|
273
273
|
build_forest(opts) do |forest|
|
274
274
|
key_attrs.each do |(full_key, attr)|
|
275
275
|
fail "Invalid key #{full_key.inspect}" if full_key.end_with?('.')
|
276
|
-
node = ::I18n::Tasks::Data::Tree::Node.new(attr.merge(key: split_key(full_key).last))
|
276
|
+
node = ::I18n::Tasks::Data::Tree::Node.new(**attr.merge(key: split_key(full_key).last))
|
277
277
|
yield(full_key, node) if block
|
278
278
|
forest[full_key] = node
|
279
279
|
end
|
@@ -60,14 +60,12 @@ module I18n::Tasks
|
|
60
60
|
self
|
61
61
|
end
|
62
62
|
|
63
|
-
def key_names(
|
64
|
-
|
65
|
-
keys(opts).map { |key, _node| key }
|
63
|
+
def key_names(root: false)
|
64
|
+
keys(root: root).map { |key, _node| key }
|
66
65
|
end
|
67
66
|
|
68
|
-
def key_values(
|
69
|
-
|
70
|
-
keys(opts).map { |key, node| [key, node.value] }
|
67
|
+
def key_values(root: false)
|
68
|
+
keys(root: root).map { |key, node| [key, node.value] }
|
71
69
|
end
|
72
70
|
|
73
71
|
def root_key_values(sort = false)
|
@@ -146,12 +144,12 @@ module I18n::Tasks
|
|
146
144
|
# @return [Siblings]
|
147
145
|
def intersect_keys(other_tree, key_opts = {}, &block)
|
148
146
|
if block
|
149
|
-
select_keys(key_opts) do |key, node|
|
147
|
+
select_keys(**key_opts.slice(:root)) do |key, node|
|
150
148
|
other_node = other_tree[key]
|
151
149
|
other_node && yield(key, node, other_node)
|
152
150
|
end
|
153
151
|
else
|
154
|
-
select_keys(key_opts) { |key, _node| other_tree[key] }
|
152
|
+
select_keys(**key_opts.slice(:root)) { |key, _node| other_tree[key] }
|
155
153
|
end
|
156
154
|
end
|
157
155
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'i18n/tasks/reports/base'
|
4
|
-
require 'i18n/tasks/rainbow_utils'
|
5
4
|
require 'terminal-table'
|
6
5
|
module I18n
|
7
6
|
module Tasks
|
@@ -76,11 +75,11 @@ module I18n
|
|
76
75
|
|
77
76
|
def forest_stats(forest, stats = task.forest_stats(forest))
|
78
77
|
text = if stats[:locale_count] == 1
|
79
|
-
I18n.t('i18n_tasks.data_stats.text_single_locale', stats)
|
78
|
+
I18n.t('i18n_tasks.data_stats.text_single_locale', **stats)
|
80
79
|
else
|
81
|
-
I18n.t('i18n_tasks.data_stats.text', stats)
|
80
|
+
I18n.t('i18n_tasks.data_stats.text', **stats)
|
82
81
|
end
|
83
|
-
title = Rainbow(I18n.t('i18n_tasks.data_stats.title', stats.slice(:locales))).bright
|
82
|
+
title = Rainbow(I18n.t('i18n_tasks.data_stats.title', **stats.slice(:locales))).bright
|
84
83
|
print_info "#{Rainbow(title).cyan} #{Rainbow(text).cyan}"
|
85
84
|
end
|
86
85
|
|
@@ -170,7 +169,7 @@ module I18n
|
|
170
169
|
end
|
171
170
|
|
172
171
|
def print_title(title)
|
173
|
-
log_stderr "#{Rainbow(title.strip).bright} #{
|
172
|
+
log_stderr "#{Rainbow(title.strip).bright} #{Rainbow('|').faint} " \
|
174
173
|
"#{"i18n-tasks v#{I18n::Tasks::VERSION}"}"
|
175
174
|
end
|
176
175
|
|
@@ -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(
|
15
|
+
TRANSLATE_CALL_RE = /(?<=^|[^\w'\-.]|[^\w'\-]I18n\.|I18n\.)t(?:!|ranslate!?)?/
|
16
16
|
IGNORE_LINES = {
|
17
17
|
'coffee' => /^\s*#(?!\si18n-tasks-use)/,
|
18
18
|
'erb' => /^\s*<%\s*#(?!\si18n-tasks-use)/,
|
@@ -15,10 +15,10 @@ module I18n::Tasks::Scanners
|
|
15
15
|
include AST::Sexp
|
16
16
|
|
17
17
|
MAGIC_COMMENT_PREFIX = /\A.\s*i18n-tasks-use\s+/
|
18
|
-
RECEIVER_MESSAGES = [nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t translate])
|
18
|
+
RECEIVER_MESSAGES = [nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t t! translate translate!])
|
19
19
|
|
20
20
|
def initialize(**args)
|
21
|
-
super(args)
|
21
|
+
super(**args)
|
22
22
|
@parser = ::Parser::CurrentRuby.new
|
23
23
|
@magic_comment_parser = ::Parser::CurrentRuby.new
|
24
24
|
@call_finder = RubyAstCallFinder.new(
|
data/lib/i18n/tasks/version.rb
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'i18n/tasks'
|
4
4
|
|
5
|
-
RSpec.describe
|
5
|
+
RSpec.describe I18n do
|
6
6
|
let(:i18n) { I18n::Tasks::BaseTask.new }
|
7
7
|
let(:missing_keys) { i18n.missing_keys }
|
8
8
|
let(:unused_keys) { i18n.unused_keys }
|
9
|
+
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }
|
9
10
|
|
10
11
|
it 'does not have missing keys' do
|
11
12
|
expect(missing_keys).to be_empty,
|
@@ -21,7 +22,13 @@ RSpec.describe 'I18n' do
|
|
21
22
|
non_normalized = i18n.non_normalized_paths
|
22
23
|
error_message = "The following files need to be normalized:\n" \
|
23
24
|
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
|
24
|
-
|
25
|
+
"Please run `i18n-tasks normalize' to fix"
|
25
26
|
expect(non_normalized).to be_empty, error_message
|
26
27
|
end
|
28
|
+
|
29
|
+
it 'does not have inconsistent interpolations' do
|
30
|
+
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
|
31
|
+
"Run `i18n-tasks check-consistent-interpolations' to show them"
|
32
|
+
expect(inconsistent_interpolations).to be_empty, error_message
|
33
|
+
end
|
27
34
|
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.
|
4
|
+
version: 0.9.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -340,7 +340,6 @@ files:
|
|
340
340
|
- lib/i18n/tasks/logging.rb
|
341
341
|
- lib/i18n/tasks/missing_keys.rb
|
342
342
|
- lib/i18n/tasks/plural_keys.rb
|
343
|
-
- lib/i18n/tasks/rainbow_utils.rb
|
344
343
|
- lib/i18n/tasks/references.rb
|
345
344
|
- lib/i18n/tasks/reports/base.rb
|
346
345
|
- lib/i18n/tasks/reports/terminal.rb
|
@@ -399,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
398
|
- !ruby/object:Gem::Version
|
400
399
|
version: '0'
|
401
400
|
requirements: []
|
402
|
-
rubygems_version: 3.
|
401
|
+
rubygems_version: 3.1.2
|
403
402
|
signing_key:
|
404
403
|
specification_version: 4
|
405
404
|
summary: Manage localization and translation with the awesome power of static analysis
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module I18n
|
4
|
-
module Tasks
|
5
|
-
module RainbowUtils
|
6
|
-
# TODO: This method can be removed after below PR is released.
|
7
|
-
# https://github.com/sickill/rainbow/pull/53
|
8
|
-
def self.faint_color(str)
|
9
|
-
presenter = Rainbow(str)
|
10
|
-
return presenter unless Rainbow.enabled
|
11
|
-
Rainbow::Presenter.new(Rainbow::StringUtils.wrap_with_sgr(presenter, [2]))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|