i18n-tasks 0.9.31 → 0.9.32

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
  SHA256:
3
- metadata.gz: b6f870248df7b94a77747317666b12fa096bd04c6c9a5fc7ab8ef8eb850a207c
4
- data.tar.gz: '092e4392eb447157a40aea73dc0214039dcd31efb09c80d0959750929765620c'
3
+ metadata.gz: bcf38124b967eb00a21ca02f9e894a22941d95e590024971144131cd61856f70
4
+ data.tar.gz: 9ffb6f291f36f0015ad22ad26981d7b605dad695f723517bb928287cd091ecaa
5
5
  SHA512:
6
- metadata.gz: 9756b702d3c268a0fd42f1f203e2c1786903433f0a7492540feeab117de3f6da018fb8d6b41c924414793b050718c71200f3fe801965178212bf13cfdd836960
7
- data.tar.gz: 85328d93b330ea66c77acf856e5d6c549a42e8dc3064487d58b4506a3ff99bb41cc6099cb5e2b44014e863353280f5e012f1d45e1d2e07139c35c4172d200793
6
+ metadata.gz: 8c27ffd3ab866c82237e99b1bea2afd444b2e9e82d0ef4b48031d46da697c079273ba6a88c4beb20a3795044096a614523aab289a46f86afc6f7e66e8719ed1e
7
+ data.tar.gz: fcb4deae9fdcadef52e7e4a6b85871fcbd33b437bc4a7a11f2c4ad42d60f2b835596bbaa86fe6ad4d30382195fd884c0728aa6fdf35fdb1b78cedb2f617bac2a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # i18n-tasks [![Build Status][badge-travis]][travis] [![Coverage Status][badge-coverage]][coverage] [![Gemnasium][badge-gemnasium]][gemnasium] [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/glebm/i18n-tasks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ # i18n-tasks [![Build Status][badge-travis]][travis] [![Coverage Status][badge-coverage]][coverage] [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/glebm/i18n-tasks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
2
 
3
3
  i18n-tasks helps you find and manage missing and unused translations.
4
4
 
@@ -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.31'
25
+ gem 'i18n-tasks', '~> 0.9.32'
26
26
  ```
27
27
 
28
28
  Copy the default [configuration file](#configuration):
@@ -437,8 +437,6 @@ Custom tasks can be added easily, see the examples [on the wiki](https://github.
437
437
  [badge-travis]: https://img.shields.io/travis/glebm/i18n-tasks.svg
438
438
  [coverage]: https://codeclimate.com/github/glebm/i18n-tasks
439
439
  [badge-coverage]: https://api.codeclimate.com/v1/badges/5d173e90ada8df07cedc/test_coverage
440
- [gemnasium]: https://gemnasium.com/glebm/i18n-tasks
441
- [badge-gemnasium]: https://gemnasium.com/glebm/i18n-tasks.svg
442
440
  [config]: https://github.com/glebm/i18n-tasks/blob/master/templates/config/i18n-tasks.yml
443
441
  [wiki]: https://github.com/glebm/i18n-tasks/wiki "i18n-tasks wiki"
444
442
  [i18n-gem]: https://github.com/svenfuchs/i18n "svenfuchs/i18n on Github"
@@ -25,7 +25,7 @@ TEXT
25
25
  TEXT
26
26
  s.homepage = 'https://github.com/glebm/i18n-tasks'
27
27
  s.metadata = { 'issue_tracker' => 'https://github.com/glebm/i18n-tasks' } if s.respond_to?(:metadata=)
28
- s.required_ruby_version = '~> 2.3' if s.respond_to?(:required_ruby_version=)
28
+ s.required_ruby_version = '>= 2.3', '< 4.0' if s.respond_to?(:required_ruby_version=)
29
29
 
30
30
  s.files = `git ls-files`.split($/)
31
31
  s.files -= s.files.grep(%r{^(doc/|\.|spec/)}) + %w[CHANGES.md config/i18n-tasks.yml Gemfile]
@@ -42,8 +42,8 @@ module I18n::Tasks
42
42
  end
43
43
 
44
44
  # late-bound I18n.t for module bodies
45
- def t(*args)
46
- proc { I18n.t(*args) }
45
+ def t(*args, **opts)
46
+ proc { I18n.t(*args, **opts) }
47
47
  end
48
48
 
49
49
  # if class is a module, merge DSL definitions when it is included
@@ -79,12 +79,8 @@ module I18n::Tasks
79
79
  def required_plural_keys_for_locale(locale)
80
80
  @plural_keys_for_locale ||= {}
81
81
  return @plural_keys_for_locale[locale] if @plural_keys_for_locale.key?(locale)
82
- @plural_keys_for_locale[locale] =
83
- begin
84
- Set.new(load_rails_i18n_pluralization!(locale)[locale.to_sym][:i18n][:plural][:keys])
85
- rescue SystemCallError, IOError
86
- Set.new
87
- end
82
+
83
+ @plural_keys_for_locale[locale] = plural_keys_for_locale(locale)
88
84
  end
89
85
 
90
86
  # Loads rails-i18n pluralization config for the given locale.
@@ -123,7 +119,7 @@ module I18n::Tasks
123
119
  end
124
120
 
125
121
  def locale_key_missing?(locale, key)
126
- !key_value?(key, locale) && !external_key?(key) && !ignore_key?(key, :missing)
122
+ !key_value?(key, locale) && !external_key?(key, locale) && !ignore_key?(key, :missing)
127
123
  end
128
124
 
129
125
  # @param [::I18n::Tasks::Data::Tree::Siblings] forest
@@ -154,5 +150,32 @@ module I18n::Tasks
154
150
  end
155
151
  forest
156
152
  end
153
+
154
+ private
155
+
156
+ def plural_keys_for_locale(locale)
157
+ configuration = load_rails_i18n_pluralization!(locale)
158
+ if configuration[locale.to_sym].nil?
159
+ alternate_locale = alternate_locale_from(locale)
160
+ return Set.new if configuration[alternate_locale.to_sym].nil?
161
+
162
+ return set_from_rails_i18n_pluralization(configuration, alternate_locale)
163
+ end
164
+ set_from_rails_i18n_pluralization(configuration, locale)
165
+ rescue SystemCallError, IOError
166
+ Set.new
167
+ end
168
+
169
+ def alternate_locale_from(locale)
170
+ re = /(\w{2})-*(\w{2,3})*/
171
+ match = locale.match(re)
172
+ language_code = match[1]
173
+ country_code = match[2]
174
+ "#{language_code}-#{country_code.upcase}"
175
+ end
176
+
177
+ def set_from_rails_i18n_pluralization(configuration, locale)
178
+ Set.new(configuration[locale.to_sym][:i18n][:plural][:keys])
179
+ end
157
180
  end
158
181
  end
@@ -17,7 +17,12 @@ module I18n::Tasks::Translators
17
17
  protected
18
18
 
19
19
  def translate_values(list, from:, to:, **options)
20
- DeepL.translate(list, to_deepl_compatible_locale(from), to_deepl_compatible_locale(to), options).map(&:text)
20
+ result = DeepL.translate(list, to_deepl_compatible_locale(from), to_deepl_compatible_locale(to), options).map(&:text)
21
+ if result.is_a?(DeepL::Resources::Text)
22
+ result.text
23
+ else
24
+ result.map(&:text)
25
+ end
21
26
  end
22
27
 
23
28
  def options_for_translate_values(**options)
@@ -25,7 +25,8 @@ module I18n::Tasks
25
25
  }.freeze
26
26
 
27
27
  ALWAYS_EXCLUDE = %w[*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
28
- *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus].freeze
28
+ *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus
29
+ *.webp].freeze
29
30
 
30
31
  # Find all keys in the source and return a forest with the keys in absolute form and their occurrences.
31
32
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Tasks
5
- VERSION = '0.9.31'
5
+ VERSION = '0.9.32'
6
6
  end
7
7
  end
@@ -32,7 +32,7 @@ data:
32
32
  # This data is not considered unused and is never written to.
33
33
  external:
34
34
  ## Example (replace %#= with %=):
35
- # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
35
+ # - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
36
36
 
37
37
  ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
38
38
  # router: conservative_router
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.31
4
+ version: 0.9.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -404,16 +404,19 @@ require_paths:
404
404
  - lib
405
405
  required_ruby_version: !ruby/object:Gem::Requirement
406
406
  requirements:
407
- - - "~>"
407
+ - - ">="
408
408
  - !ruby/object:Gem::Version
409
409
  version: '2.3'
410
+ - - "<"
411
+ - !ruby/object:Gem::Version
412
+ version: '4.0'
410
413
  required_rubygems_version: !ruby/object:Gem::Requirement
411
414
  requirements:
412
415
  - - ">="
413
416
  - !ruby/object:Gem::Version
414
417
  version: '0'
415
418
  requirements: []
416
- rubygems_version: 3.0.3
419
+ rubygems_version: 3.1.2
417
420
  signing_key:
418
421
  specification_version: 4
419
422
  summary: Manage localization and translation with the awesome power of static analysis