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 +4 -4
- data/CHANGES.md +4 -0
- data/README.md +3 -3
- data/bin/i18n-tasks +3 -1
- data/i18n-tasks.gemspec +2 -1
- data/lib/i18n/tasks/commands.rb +6 -6
- data/lib/i18n/tasks/commands_base.rb +7 -9
- data/lib/i18n/tasks/version.rb +1 -1
- metadata +1 -2
- data/doc/img/i18n-tasks.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4e945701c214bce20eae1f33712a492c7fc5a4
|
4
|
+
data.tar.gz: 6d0c3c00118605d0fa155c892303a5bd0aa9992b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b08ab8e84bb4854b609fb3de6029d72941663cca91afa35d08c321df38602a25b3605b6418641d72b06c08af812d951cf0ed6661ca55f645b26c12f92172869
|
7
|
+
data.tar.gz: c800186476d035a8a256afb7981123e879e46d744719e62f7bfe9ec61465c872193426f8222a24b4615e8e1dc92d82106201882c7e1b7c73280213a100b626ff
|
data/CHANGES.md
CHANGED
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
|
61
|
-
i18n-tasks add-missing
|
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
|
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
|
-
|
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($/)
|
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']
|
data/lib/i18n/tasks/commands.rb
CHANGED
@@ -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[:
|
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[:
|
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(
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
11
|
+
i18n_task.locales
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
data/lib/i18n/tasks/version.rb
CHANGED
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.
|
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
|
data/doc/img/i18n-tasks.png
DELETED
Binary file
|