i18n-tasks 0.5.2 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0268bd9f81bcf59f191082abc4d7659858b01307
4
- data.tar.gz: 0feb0bd995b09220bb7ae0843a3cc67c01cfd938
3
+ metadata.gz: 6c261d8b23e8817ba86c745be24cb3fa56c96443
4
+ data.tar.gz: 2228dcb943e500a2c901bcdb3b0a9fa292de6ef7
5
5
  SHA512:
6
- metadata.gz: 3514ce68ee51f2b90028fbb87cd5b1e249cc66ebe41f9b746e65d39e87b00b2a372099f8e3d2abf9f28e829d0e8cb8d6fc68f64c6ac6c25f029aa307d8b37c5e
7
- data.tar.gz: 339eec064e4f2fa5b52182113aafe7f819ef2c5d1917901556a0f3d228e85ef661afb640876677b653fdfb1327adc0539ab447e3d2b8c41f8c0fe3327e148d8a
6
+ metadata.gz: 361d00affbc2d10ca407b86b40c6c46a28b79d9bfaf0102ff4cce08b82b9fdd11aee1c45a43ab0de60b7208094eacdff97ec7cacab1742bdc41f05ee620e435a
7
+ data.tar.gz: e38f00ef20108497b456c8a8039d33d9593bde583543fe6773a90a206662a6d1b7a441861c33e138ef092dd453a1c25870a80ad76486e1aafec1485093246717
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.5.3
2
+
3
+ * Fix Google translate regression
4
+ * More robust config output
5
+
1
6
  ## 0.5.2
2
7
 
3
8
  * Ignore lines during search with `config.search.ignore_lines`. Ignores comments by default.
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.2'
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
- count = i18n.missing_keys.leaves.count
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
- count = i18n.unused_keys.leaves.count
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
- # hide empty sections, stringify keys
110
- Hash[config_sections.reject { |k, v| v.nil? || v.empty? }.map { |k, v|
111
- [k.to_s, v.respond_to?(:deep_stringify_keys) ? v.deep_stringify_keys.to_hash : v] }].tap do |h|
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
@@ -46,7 +46,8 @@ module I18n::Tasks::Data::Tree
46
46
 
47
47
  def each(&block)
48
48
  return to_enum(:each) { 1 } unless block
49
- [self].each(&block)
49
+ block.yield(self)
50
+ self
50
51
  end
51
52
 
52
53
  include Enumerable
@@ -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
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.3'
5
5
  end
6
6
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm