i18n-tasks 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/README.md +12 -9
- data/bin/i18n-tasks +0 -0
- data/bin/i18n-tasks.cmd +0 -0
- data/config/locales/en.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/i18n-tasks.gemspec +3 -3
- data/lib/i18n/tasks/command/commands/missing.rb +15 -3
- data/lib/i18n/tasks/command/option_parsers/locale.rb +8 -1
- data/lib/i18n/tasks/data/tree/traversal.rb +2 -0
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/commands/missing_commands_spec.rb +23 -0
- data/spec/i18n_tasks_spec.rb +11 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b7283fc75cd948d4e33223d13c310da41c71249
|
4
|
+
data.tar.gz: a0cbd7255e3306869faec54d994c26659e9c2334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b79a50af3669c354a7c7ebc8acbf6ae6587bb344048b92d89656ab1474b241121ae9794637399ca4a47ec4abe9d383a0b25681aa6c0e26c43e18743c004295
|
7
|
+
data.tar.gz: ec135b8e1b5638443228fe9d0ec4144876b6e3c8e9fc85cffea9b7c38c1cf6e4d8f79d00c8d9cb2ad2123cfb30a3909bf6ddb6bce186c94f1112e341f043c0bc
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.8.7
|
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)
|
5
|
+
|
1
6
|
## 0.8.6
|
2
7
|
|
3
8
|
* Report missing keys found in source in all the locales. [#162](https://github.com/glebm/i18n-tasks/issues/162)
|
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.
|
27
|
+
gem 'i18n-tasks', '~> 0.8.7'
|
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}. Default: %{value_or_human_key}.
|
75
|
+
-v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}, %{key}. Default: %{value_or_human_key}.
|
76
76
|
-h, --help Display this help message.
|
77
77
|
```
|
78
78
|
|
@@ -124,18 +124,21 @@ $ i18n-tasks normalize -p
|
|
124
124
|
|
125
125
|
### Compose tasks
|
126
126
|
|
127
|
-
`i18n-tasks` also provides composable tasks for reading, writing and manipulating locale data.
|
128
|
-
|
129
|
-
For example, `add-missing` implemented with `missing`, `tree-set-value` and `data-merge`:
|
127
|
+
`i18n-tasks` also provides composable tasks for reading, writing and manipulating locale data. Examples below.
|
130
128
|
|
129
|
+
`add-missing` implemented with `missing`, `tree-set-value` and `data-merge`:
|
131
130
|
```console
|
132
|
-
$ i18n-tasks missing -
|
131
|
+
$ i18n-tasks missing -f yaml fr | i18n-tasks tree-set-value 'TRME %{value}' | i18n-tasks data-merge
|
133
132
|
```
|
134
133
|
|
135
|
-
|
134
|
+
`remove-unused` implemented with `unused` and `data-remove` (sans the confirmation):
|
135
|
+
```console
|
136
|
+
$ i18n-tasks unused -f yaml | i18n-tasks data-remove
|
137
|
+
```
|
136
138
|
|
137
|
-
|
138
|
-
|
139
|
+
Remove all keys in `fr` but not `en` from `fr`:
|
140
|
+
```console
|
141
|
+
$ i18n-tasks missing -t diff -f yaml en | i18n-tasks tree-rename-key en fr | i18n-tasks data-remove
|
139
142
|
```
|
140
143
|
|
141
144
|
See the full list of tasks with `i18n-tasks --help`.
|
data/bin/i18n-tasks
CHANGED
File without changes
|
data/bin/i18n-tasks.cmd
CHANGED
File without changes
|
data/config/locales/en.yml
CHANGED
@@ -22,7 +22,7 @@ en:
|
|
22
22
|
out_format: 'Output format: %{valid_text}'
|
23
23
|
pattern_router: 'Use pattern router: keys moved per config data.write'
|
24
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}'
|
25
|
+
value: 'Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}, %{key}'
|
26
26
|
desc:
|
27
27
|
add_missing: add missing keys to locale data
|
28
28
|
config: display i18n-tasks configuration
|
data/config/locales/ru.yml
CHANGED
@@ -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}"
|
24
|
+
value: "Значение, интерполируется с %{value}, %{human_key}, %{value_or_human_key}, %{key}"
|
25
25
|
desc:
|
26
26
|
add_missing: "добавить недостающие ключи к переводам"
|
27
27
|
config: "показать конфигурацию"
|
data/i18n-tasks.gemspec
CHANGED
@@ -34,11 +34,11 @@ TEXT
|
|
34
34
|
s.require_paths = ['lib']
|
35
35
|
|
36
36
|
s.add_dependency 'erubis'
|
37
|
-
s.add_dependency 'activesupport'
|
37
|
+
s.add_dependency 'activesupport', '>= 2.3.18'
|
38
38
|
s.add_dependency 'easy_translate', '>= 0.5.0'
|
39
|
-
s.add_dependency 'term-ansicolor'
|
39
|
+
s.add_dependency 'term-ansicolor', '>= 1.3.2'
|
40
40
|
s.add_dependency 'terminal-table', '>= 1.5.1'
|
41
|
-
s.add_dependency 'highline'
|
41
|
+
s.add_dependency 'highline', '>= 1.7.3'
|
42
42
|
s.add_dependency 'i18n'
|
43
43
|
s.add_development_dependency 'axlsx', '~> 2.0'
|
44
44
|
s.add_development_dependency 'bundler', '~> 1.3'
|
@@ -47,10 +47,22 @@ 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
|
-
|
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])
|
51
62
|
i18n.data.merge! forest
|
52
|
-
|
53
|
-
|
63
|
+
added.merge! forest
|
64
|
+
log_stderr t('i18n_tasks.add_missing.added', count: added.leaves.count)
|
65
|
+
print_forest added, opt
|
54
66
|
end
|
55
67
|
end
|
56
68
|
end
|
@@ -36,11 +36,18 @@ module I18n::Tasks
|
|
36
36
|
if vals == %w(all) || vals.blank?
|
37
37
|
context.locales
|
38
38
|
else
|
39
|
-
vals.map { |v| v == 'base' ? context.base_locale : v }
|
39
|
+
move_base_locale_to_front! vals.map { |v| v == 'base' ? context.base_locale : v }, context.base_locale
|
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
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
@@ -147,10 +147,12 @@ module I18n::Tasks
|
|
147
147
|
value_proc ||= proc { |node|
|
148
148
|
node_value = node.value
|
149
149
|
human_key = ActiveSupport::Inflector.humanize(node.key.to_s)
|
150
|
+
full_key = node.full_key
|
150
151
|
StringInterpolation.interpolate_soft(
|
151
152
|
val_pattern,
|
152
153
|
value: node_value,
|
153
154
|
human_key: human_key,
|
155
|
+
key: full_key,
|
154
156
|
value_or_human_key: node_value.presence || human_key
|
155
157
|
)
|
156
158
|
}
|
data/lib/i18n/tasks/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Data commands' do
|
4
|
+
delegate :run_cmd, to: :TestCodebase
|
5
|
+
|
6
|
+
describe '#add_missing' do
|
7
|
+
describe 'adds the missing keys to base locale first, then to other locales' do
|
8
|
+
around do |ex|
|
9
|
+
TestCodebase.setup(
|
10
|
+
'config/i18n-tasks.yml' => {base_locale: 'en', locales: %w(es fr)}.to_yaml,
|
11
|
+
'config/locales/es.yml' => {'es' => {'a' => 'A'}}.to_yaml)
|
12
|
+
TestCodebase.in_test_app_dir { ex.call }
|
13
|
+
TestCodebase.teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'with -v argument' do
|
17
|
+
run_cmd 'add-missing', '-vTRME'
|
18
|
+
expect(YAML.load_file('config/locales/en.yml')).to eq('en' => {'a' => 'TRME'})
|
19
|
+
expect(YAML.load_file('config/locales/fr.yml')).to eq('fr' => {'a' => 'TRME'})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/i18n_tasks_spec.rb
CHANGED
@@ -211,6 +211,17 @@ RSpec.describe 'i18n-tasks' do
|
|
211
211
|
expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'TRME ES_TEXT'
|
212
212
|
}
|
213
213
|
end
|
214
|
+
|
215
|
+
it '--value with %{key}' do
|
216
|
+
in_test_app_dir {
|
217
|
+
expect(YAML.load_file('config/locales/es.yml')['es']['missing_in_es']).to be_nil
|
218
|
+
}
|
219
|
+
run_cmd 'add-missing', '-v', 'TRME %{key}'
|
220
|
+
in_test_app_dir {
|
221
|
+
expect(YAML.load_file('config/locales/es.yml')['es']['missing_in_es']['a']).to eq 'TRME es.missing_in_es.a'
|
222
|
+
expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'TRME en.present_in_es_but_not_en.a'
|
223
|
+
}
|
224
|
+
end
|
214
225
|
end
|
215
226
|
|
216
227
|
describe 'config' do
|
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.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.3.18
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.3.18
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: easy_translate
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.3.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.3.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: terminal-table
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.7.3
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.7.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: i18n
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,6 +264,7 @@ files:
|
|
264
264
|
- lib/i18n/tasks/used_keys.rb
|
265
265
|
- lib/i18n/tasks/version.rb
|
266
266
|
- spec/commands/data_commands_spec.rb
|
267
|
+
- spec/commands/missing_commands_spec.rb
|
267
268
|
- spec/commands/tree_commands_spec.rb
|
268
269
|
- spec/conservative_router_spec.rb
|
269
270
|
- spec/file_system_data_spec.rb
|
@@ -320,12 +321,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
320
321
|
version: '0'
|
321
322
|
requirements: []
|
322
323
|
rubyforge_project:
|
323
|
-
rubygems_version: 2.4.
|
324
|
+
rubygems_version: 2.4.5
|
324
325
|
signing_key:
|
325
326
|
specification_version: 4
|
326
327
|
summary: Manage localization and translation with the awesome power of static analysis
|
327
328
|
test_files:
|
328
329
|
- spec/commands/data_commands_spec.rb
|
330
|
+
- spec/commands/missing_commands_spec.rb
|
329
331
|
- spec/commands/tree_commands_spec.rb
|
330
332
|
- spec/conservative_router_spec.rb
|
331
333
|
- spec/file_system_data_spec.rb
|
@@ -355,3 +357,4 @@ test_files:
|
|
355
357
|
- spec/support/test_codebase.rb
|
356
358
|
- spec/support/trees.rb
|
357
359
|
- spec/used_keys_spec.rb
|
360
|
+
has_rdoc:
|