i18n-tasks 0.5.2 → 0.5.3
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 +3 -5
- data/lib/i18n/tasks/configuration.rb +16 -7
- data/lib/i18n/tasks/data/tree/node.rb +2 -1
- data/lib/i18n/tasks/fill_tasks.rb +1 -1
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/google_translate_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c261d8b23e8817ba86c745be24cb3fa56c96443
|
4
|
+
data.tar.gz: 2228dcb943e500a2c901bcdb3b0a9fa292de6ef7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361d00affbc2d10ca407b86b40c6c46a28b79d9bfaf0102ff4cce08b82b9fdd11aee1c45a43ab0de60b7208094eacdff97ec7cacab1742bdc41f05ee620e435a
|
7
|
+
data.tar.gz: e38f00ef20108497b456c8a8039d33d9593bde583543fe6773a90a206662a6d1b7a441861c33e138ef092dd453a1c25870a80ad76486e1aafec1485093246717
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ i18n-tasks can be used with any project using [i18n][i18n-gem] (default in Rails
|
|
18
18
|
Add to Gemfile:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem 'i18n-tasks', '~> 0.5.
|
21
|
+
gem 'i18n-tasks', '~> 0.5.3'
|
22
22
|
```
|
23
23
|
|
24
24
|
|
@@ -331,13 +331,11 @@ describe 'I18n' do
|
|
331
331
|
let(:i18n) { I18n::Tasks::BaseTask.new }
|
332
332
|
|
333
333
|
it 'does not have missing keys' do
|
334
|
-
|
335
|
-
fail "There are #{count} missing i18n keys! Run 'i18n-tasks missing' for more details." unless count.zero?
|
334
|
+
expect(i18n.missing_keys).to be_empty
|
336
335
|
end
|
337
336
|
|
338
337
|
it 'does not have unused keys' do
|
339
|
-
|
340
|
-
fail "There are #{count} unused i18n keys! Run 'i18n-tasks unused' for more details." unless count.zero?
|
338
|
+
expect(i18n.unused_keys).to be_empty
|
341
339
|
end
|
342
340
|
end
|
343
341
|
```
|
@@ -106,14 +106,23 @@ module I18n::Tasks::Configuration
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def config_for_inspect
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
h.each do |_k, v|
|
113
|
-
if v.is_a?(Hash) && v.key?('config')
|
114
|
-
v.merge! v.delete('config')
|
115
|
-
end
|
109
|
+
to_hash_from_indifferent(config_sections.deep_stringify_keys.reject { |k, v| v.blank? }).tap do |sections|
|
110
|
+
sections.each do |_k, section|
|
111
|
+
section.merge! section.delete('config') if Hash === section && section.key?('config')
|
116
112
|
end
|
117
113
|
end
|
118
114
|
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def to_hash_from_indifferent(v)
|
119
|
+
case v
|
120
|
+
when Hash
|
121
|
+
v.to_hash
|
122
|
+
when Array
|
123
|
+
v.map { |e| to_hash_from_indifferent e }
|
124
|
+
else
|
125
|
+
v
|
126
|
+
end
|
127
|
+
end
|
119
128
|
end
|
@@ -20,7 +20,7 @@ module I18n::Tasks
|
|
20
20
|
keys = missing_tree(locale, from).key_names.map(&:to_s)
|
21
21
|
values = google_translate(keys.zip(keys.map(&t_proc(from))), to: locale, from: from).map(&:last)
|
22
22
|
|
23
|
-
data[locale] = Data::Tree::Node.new(
|
23
|
+
data[locale] = data[locale].merge! Data::Tree::Node.new(
|
24
24
|
key: locale,
|
25
25
|
children: Data::Tree::Siblings.from_flat_pairs(keys.zip(values))
|
26
26
|
).to_siblings
|
data/lib/i18n/tasks/version.rb
CHANGED
@@ -40,13 +40,21 @@ describe 'Google Translation' do
|
|
40
40
|
in_test_app_dir do
|
41
41
|
task.data[:en] = build_tree('en' => {
|
42
42
|
'common' => {
|
43
|
+
'a' => 'λ',
|
43
44
|
'hello' => text_test[1],
|
44
45
|
'hello_html' => html_test[1]
|
45
46
|
}
|
46
47
|
})
|
48
|
+
task.data[:es] = build_tree('es' =>{
|
49
|
+
'common' => {
|
50
|
+
'a' => 'λ',
|
51
|
+
}
|
52
|
+
})
|
53
|
+
|
47
54
|
cmd.translate_missing
|
48
55
|
expect(task.t('common.hello', 'es')).to eq(text_test[2])
|
49
56
|
expect(task.t('common.hello_html', 'es')).to eq(html_test[2])
|
57
|
+
expect(task.t('common.a', 'es')).to eq('λ')
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|