i18n-tasks 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fc0724b7e7b8840f7043fed0dbe4057f344a81d
4
- data.tar.gz: 074fcc2b73960b4f0558c983a43a363831ea76a0
3
+ metadata.gz: a5b450d463f4c435b2c29cb8625c0fc3b2f1f0fc
4
+ data.tar.gz: 8f3a640623471a782e3a3321aae671f51bf4c94d
5
5
  SHA512:
6
- metadata.gz: ee3d14aecdad57a50957879f5b54ca48557f133aacfaa957ac6dc4a9ff118e5e22cafb2fbc511f46250b0003611ac83d8c09d435edbc2e3437bb14cdaa756ddc
7
- data.tar.gz: d371fcbb050c80fa44bf3bf9db7fbaba474c30296a24b001f8f91b1e7069778ba904660b8d4ba14d0c075ddcb00dcb9722aedc156587b64a7fc8978c86dde1f9
6
+ metadata.gz: 6d95d020a9f643480f5e8022b69976355aafe6ed66955eeeb12a25f12c3aa4bce11f3d10e5807c29636690f087f289e089b21fc0634b251b26090f83690037a5
7
+ data.tar.gz: 0f2186c5897c723eb587af3471214c6b372590ce8f79e615aeb32afb7627aba003772061a44f2165908aeb000bd2067a64d077bbd7395fd85f04ef2d86617b64
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.4
2
+
3
+ * Fix google translate issues with plural keys and translating from non-base locale
4
+
1
5
  ## 0.4.3
2
6
 
3
7
  * Ruby 1.9 compatibility
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'coveralls', require: false
8
- gem 'byebug', platform: :mri_20, require: false
8
+ gem 'byebug', platform: :mri_21, require: false
9
9
  end
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.4.3'
21
+ gem 'i18n-tasks', '~> 0.4.4'
22
22
  ```
23
23
 
24
24
  i18n-tasks does not load or execute any of the application's code but performs static-only analysic.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # coding: utf-8
2
3
 
3
4
  require 'i18n/tasks'
4
5
  require 'i18n/tasks/commands'
@@ -21,6 +21,12 @@ module I18n::Tasks
21
21
  data.t(key, locale)
22
22
  end
23
23
 
24
+ def missing_tree(locale, compared_to = base_locale)
25
+ data[compared_to].select_keys(root: false) { |key, node|
26
+ !key_value?(key, locale) && !ignore_key?(key, :missing)
27
+ }
28
+ end
29
+
24
30
  def tree(locale)
25
31
  data[locale][locale].children
26
32
  end
@@ -32,6 +32,10 @@ module I18n::Tasks::Data::Tree
32
32
  @hash ||= map(&:to_hash).reduce(:deep_merge!) || {}
33
33
  end
34
34
 
35
+ def key_names
36
+ keys(root: false).map { |key, _node| key }
37
+ end
38
+
35
39
  delegate :to_json, to: :to_hash
36
40
  delegate :to_yaml, to: :to_hash
37
41
 
@@ -11,8 +11,8 @@ module I18n::Tasks::FillTasks
11
11
  def fill_missing_google_translate(opts = {})
12
12
  from = opts[:from] || base_locale
13
13
  opts = opts.merge(
14
- locales: non_base_locales(opts[:locales]),
15
- keys: proc { |locale| keys_to_fill(locale).select(&t_proc(from)).select { |k| t(k).is_a?(String) } },
14
+ locales: Array(opts[:locales]) - Array(from),
15
+ keys: proc { |locale| missing_tree(locale, from).key_names.map(&:to_s) },
16
16
  values: proc { |keys, locale|
17
17
  google_translate(keys.zip(keys.map(&t_proc(from))), to: locale, from: from).map(&:last)
18
18
  }
@@ -42,11 +42,7 @@ module I18n::Tasks
42
42
  return keys_missing_from_base if locale == base_locale
43
43
  @keys_missing_from_locale ||= {}
44
44
  @keys_missing_from_locale[locale] ||= begin
45
- keys = data[base_locale].keys(root: false).map { |key, node|
46
- key = depluralize_key(key, locale)
47
- next if ignore_key?(key, :missing) || key_value?(key, locale)
48
- key
49
- }.compact.uniq
45
+ keys = missing_tree(locale).key_names.map { |key| depluralize_key(key, locale) }.uniq
50
46
  KeyGroup.new keys, type: :missing_from_locale, locale: locale
51
47
  end
52
48
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.4.3'
4
+ VERSION = '0.4.4'
5
5
  end
6
6
  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.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis