i18n-tasks 0.3.1 → 0.3.2

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: 8450eafca8f0cbffefa8b34ff0a3418b96798310
4
- data.tar.gz: f68636e26f49cc27d285ee7d23c0eb94f407ea22
3
+ metadata.gz: 9a4e945701c214bce20eae1f33712a492c7fc5a4
4
+ data.tar.gz: 6d0c3c00118605d0fa155c892303a5bd0aa9992b
5
5
  SHA512:
6
- metadata.gz: 419092e4764354330ed956e7d400d250316be9cb3bba46a023affc67b9e1e01fe4dd266ffabb390e5506e31a7b35bd0225e659b551eab79848997566f640dbdb
7
- data.tar.gz: ef5ff0ee61e3bf68f282eea0afd4b21a3605d82dc58f8a423f824694b5d547d2dc3718b1dadf5e19f1e12d9a5baa6b1cdb86f360ea8b085abc7e9e3ff1e63640
6
+ metadata.gz: 4b08ab8e84bb4854b609fb3de6029d72941663cca91afa35d08c321df38602a25b3605b6418641d72b06c08af812d951cf0ed6661ca55f645b26c12f92172869
7
+ data.tar.gz: c800186476d035a8a256afb7981123e879e46d744719e62f7bfe9ec61465c872193426f8222a24b4615e8e1dc92d82106201882c7e1b7c73280213a100b626ff
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.3.2
2
+
3
+ * Tasks that accept locales now accept them as the first argument(s)
4
+
1
5
  ## v0.3.0
2
6
 
3
7
  * i18n-tasks is a binary now (instead of rake tasks). All tasks / commands now accept various options, and there is no need for as many of them as before.
data/README.md CHANGED
@@ -57,8 +57,8 @@ Add missing values, generated from the key (for base locale) or copied from the
57
57
  To add missing values to the base locale only:
58
58
 
59
59
  ```bash
60
- # locales argument always accepts `base` and `all` as special values
61
- i18n-tasks add-missing -l base
60
+ # most task accept locales as first argument. `base` and `all` are special
61
+ i18n-tasks add-missing base
62
62
  ```
63
63
 
64
64
  Translate missing values with Google Translate ([more below on the API key](#translation-config)).
@@ -66,7 +66,7 @@ Translate missing values with Google Translate ([more below on the API key](#tra
66
66
  ```bash
67
67
  i18n-tasks translate-missing
68
68
  # accepts from and locales options:
69
- i18n-tasks translate-missing -f base -l es,fr
69
+ i18n-tasks translate-missing --from base es fr
70
70
  ```
71
71
 
72
72
  Sort the keys and write them to their respective files with `normalize`.
data/bin/i18n-tasks CHANGED
@@ -28,7 +28,9 @@ if command
28
28
  cmd.send meth
29
29
  else
30
30
  opt = command[1].to_hash.merge(arguments: command[2])
31
- STDERR.puts Term::ANSIColor.green "i18n-tasks: #{meth.tr('_', '-')} #{opt.reject { |k, v| v.blank? }.map { |k, v| "#{k}=#{v}" } * ' '}"
31
+ if ENV['VERBOSE']
32
+ STDERR.puts Term::ANSIColor.green "i18n-tasks: #{meth.tr('_', '-')} #{opt.reject { |k, v| v.blank? }.map { |k, v| "#{k}=#{v}" } * ' '}"
33
+ end
32
34
  cmd.send meth, opt
33
35
  end
34
36
  else
data/i18n-tasks.gemspec CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
19
19
  end
20
20
  s.license = 'MIT'
21
21
 
22
- s.files = `git ls-files`.split($/) - %w(doc/img/i18n-tasks.gif doc/img/i18n-usages.png)
22
+ s.files = `git ls-files`.split($/)
23
+ s.files -= s.files.grep(%r{^doc/img/})
23
24
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
25
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
25
26
  s.require_paths = ['lib']
@@ -13,7 +13,7 @@ module I18n::Tasks
13
13
  on '-t', :types, 'Filter by type (types: missing_from_base, eq_base, missing_from_locale)', as: Array, delimiter: /[+:,]/, argument: true, optional: false
14
14
  end
15
15
  cmd :missing do |opt = {}|
16
- opt[:locales] = locales_opt(opt[:locales])
16
+ opt[:locales] = locales_opt(opt[:arguments] || opt[:locales])
17
17
  terminal_report.missing_keys i18n_task.missing_keys(opt)
18
18
  end
19
19
 
@@ -29,17 +29,17 @@ module I18n::Tasks
29
29
  end
30
30
  cmd :translate_missing do |opt = {}|
31
31
  opt[:from] = base_locale if opt[:from].blank? || opt[:from] == 'base'
32
- opt[:locales] = locales_opt(opt[:locale] || opt[:locales])
32
+ opt[:locales] = locales_opt(opt[:arguments] || opt[:locales])
33
33
  i18n_task.fill_missing_google_translate opt
34
34
  end
35
35
 
36
36
  desc 'add missing keys to the locales'
37
37
  opts do
38
- on '-p', :placeholder, 'Value for empty keys (default: base value or key.humanize)', argument: true, optional: false
39
38
  on '-l', :locales, 'Only for specified locales', as: Array, delimiter: /[+:,]/, default: 'all', argument: true, optional: false
39
+ on '-p', :placeholder, 'Value for empty keys (default: base value or key.humanize)', argument: true, optional: false
40
40
  end
41
41
  cmd :add_missing do |opt = {}|
42
- opt[:locales] = locales_opt(opt[:locale] || opt[:locales])
42
+ opt[:locales] = locales_opt(opt[:arguments] || opt[:locales])
43
43
  opt[:value] ||= opt.delete(:placeholder)
44
44
  opt[:value] ||= proc { |key, locale|
45
45
  # default to base value or key.humanize
@@ -66,7 +66,7 @@ module I18n::Tasks
66
66
  on '-l', :locales=, 'Only for specified locales', as: Array, delimiter: /[+:,]/, default: 'all', argument: true, optional: false
67
67
  end
68
68
  cmd :normalize do |opt = {}|
69
- i18n_task.normalize_store! locales_opt(opt[:locales])
69
+ i18n_task.normalize_store! locales_opt(opt[:arguments] || opt[:locales])
70
70
  end
71
71
 
72
72
  desc 'remove unused keys'
@@ -74,7 +74,7 @@ module I18n::Tasks
74
74
  on '-l', :locales=, 'Only for specified locales', as: Array, delimiter: /[+:,]/, default: 'all', argument: true, optional: false
75
75
  end
76
76
  cmd :remove_unused do |opt = {}|
77
- locales = locales_opt opt[:locales]
77
+ locales = locales_opt(opt[:arguments] || opt[:locales])
78
78
  unused_keys = i18n_task.unused_keys
79
79
  if unused_keys.present?
80
80
  terminal_report.unused_keys(unused_keys)
@@ -1,16 +1,14 @@
1
1
  require 'ostruct'
2
2
  module I18n::Tasks
3
3
  class CommandsBase
4
- def locales_opt(value, default = nil)
5
- if value.is_a?(String)
6
- value = value.strip.split(/\s*\+\s*/).compact.presence
7
- end
8
- return i18n_task.locales if value == ['all']
9
- if value.present?
10
- value = value.map { |v| v == 'base' ? base_locale : v }
11
- value
4
+ def locales_opt(locales)
5
+ return i18n_task.locales if locales == ['all'] || locales == 'all'
6
+ if locales.present?
7
+ locales = Array(locales).map { |v| v.strip.split(/\s*[\+,:]\s*/).compact.presence if v.is_a?(String) }.flatten
8
+ locales = locales.map(&:presence).compact.map { |v| v == 'base' ? base_locale : v }
9
+ locales
12
10
  else
13
- default || i18n_task.locales
11
+ i18n_task.locales
14
12
  end
15
13
  end
16
14
 
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Tasks
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
@@ -198,7 +198,6 @@ files:
198
198
  - README.md
199
199
  - Rakefile
200
200
  - bin/i18n-tasks
201
- - doc/img/i18n-tasks.png
202
201
  - i18n-tasks.gemspec
203
202
  - lib/i18n/tasks.rb
204
203
  - lib/i18n/tasks/base_task.rb
Binary file