translations_sync 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +3 -0
- data/Rakefile +1 -1
- data/lib/tasks/translations_sync.rake +6 -5
- data/lib/translations_sync.rb +6 -1
- metadata +54 -35
- checksums.yaml +0 -7
data/Changelog
CHANGED
data/Rakefile
CHANGED
@@ -8,10 +8,10 @@ namespace :translations do
|
|
8
8
|
TranslationsSync.new ENV['LIST'], ENV['EXCLUDE'], source
|
9
9
|
end
|
10
10
|
|
11
|
-
def save_files(translations, default_name)
|
11
|
+
def save_files(translations, default_name, separator = '_')
|
12
12
|
name = ENV['NAME'] || ENV['IN'] || default_name
|
13
13
|
translations.keys.sort.each do |lang|
|
14
|
-
filename = File.join Rails.root, 'config', 'locales', "#{name}
|
14
|
+
filename = File.join Rails.root, 'config', 'locales', "#{name}#{separator}#{lang}.yml"
|
15
15
|
print filename + ' ... '
|
16
16
|
if File.exist? filename
|
17
17
|
status = 'updated'
|
@@ -30,7 +30,8 @@ namespace :translations do
|
|
30
30
|
ts = get_ts
|
31
31
|
name = ENV['NAME'] || ENV['IN'] || 'missing'
|
32
32
|
ts.missing.keys.sort.each do |lang|
|
33
|
-
filename = File.join Rails.root, 'config', 'locales',
|
33
|
+
filename = File.join Rails.root, 'config', 'locales',
|
34
|
+
"#{name}#{ts.separator}#{lang}.yml"
|
34
35
|
print filename + ' ... '
|
35
36
|
if File.exist? filename
|
36
37
|
hash = YAML::load(File.open(filename))
|
@@ -67,7 +68,7 @@ namespace :translations do
|
|
67
68
|
key = ENV['KEY'] or raise "Parameter KEY must be given"
|
68
69
|
ts = get_ts
|
69
70
|
if ts.move key, ENV['TO']
|
70
|
-
save_files ts.moved, 'moved'
|
71
|
+
save_files ts.moved, 'moved', ts.separator
|
71
72
|
else
|
72
73
|
puts "The key \"#{key}\" was not found"
|
73
74
|
end
|
@@ -78,7 +79,7 @@ namespace :translations do
|
|
78
79
|
key = ENV['KEY'] or raise "Parameter KEY must be given"
|
79
80
|
ts = get_ts
|
80
81
|
if ts.remove key
|
81
|
-
save_files ts.moved, 'removed'
|
82
|
+
save_files ts.moved, 'removed', ts.separator
|
82
83
|
else
|
83
84
|
puts "The key \"#{key}\" was not found"
|
84
85
|
end
|
data/lib/translations_sync.rb
CHANGED
@@ -80,10 +80,11 @@ class TranslationsSync
|
|
80
80
|
end
|
81
81
|
|
82
82
|
if source
|
83
|
-
re = Regexp.new "\\/#{Regexp.escape source}_[a-z]{2}(-[A-Z]{2})?\\.(yml|rb)\\Z"
|
83
|
+
re = Regexp.new "\\/#{Regexp.escape source}(_|.)[a-z]{2}(-[A-Z]{2})?\\.(yml|rb)\\Z"
|
84
84
|
I18n.load_path.reject! do |path|
|
85
85
|
path !~ re
|
86
86
|
end
|
87
|
+
@separator = $1 == '.' ? '.' : '_'
|
87
88
|
translations.each do |key, hash|
|
88
89
|
hash.keys.each do |k|
|
89
90
|
hash.delete(k) unless k == :pluralize
|
@@ -212,6 +213,10 @@ class TranslationsSync
|
|
212
213
|
result
|
213
214
|
end
|
214
215
|
|
216
|
+
def separator
|
217
|
+
@separator || '_'
|
218
|
+
end
|
219
|
+
|
215
220
|
private
|
216
221
|
|
217
222
|
def flatten_keys(lang, src, dest = {}, prefix = [])
|
metadata
CHANGED
@@ -1,38 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: translations_sync
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Dmitri Koulikoff
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-05-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
14
21
|
name: ya2yaml
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
22
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
27
34
|
description: Synchronizes the different locales represeinted in yaml for I18n
|
28
35
|
email: koulikoff@gmail.com
|
29
|
-
executables:
|
36
|
+
executables:
|
30
37
|
- translations_sync
|
31
38
|
extensions: []
|
32
|
-
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
33
41
|
- README
|
34
42
|
- MIT-LICENSE
|
35
|
-
files:
|
43
|
+
files:
|
36
44
|
- MIT-LICENSE
|
37
45
|
- README
|
38
46
|
- Rakefile
|
@@ -44,25 +52,36 @@ files:
|
|
44
52
|
- spec/spec_helper.rb
|
45
53
|
homepage: http://github.com/dima4p/translations_sync/
|
46
54
|
licenses: []
|
47
|
-
|
55
|
+
|
48
56
|
post_install_message:
|
49
57
|
rdoc_options: []
|
50
|
-
|
58
|
+
|
59
|
+
require_paths:
|
51
60
|
- lib
|
52
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
62
79
|
requirements: []
|
80
|
+
|
63
81
|
rubyforge_project:
|
64
|
-
rubygems_version:
|
82
|
+
rubygems_version: 1.8.15
|
65
83
|
signing_key:
|
66
|
-
specification_version:
|
84
|
+
specification_version: 3
|
67
85
|
summary: Synchronizes the different locales represeinted in yaml for I18n
|
68
86
|
test_files: []
|
87
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 810c9cf4cf006c63094f8322f7eaa2f5d15a1711
|
4
|
-
data.tar.gz: 4e750117adff000a4443b257e82047ce8361c9a4
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 3e37d4e834b6fe9decf29bc8cc8dc948be115324a9cd7f52db371639ccbc7c6c294604d61ede13fcd132e533035811d2c89edf9f9f7bd7e644cdba6d724a696e
|
7
|
-
data.tar.gz: bf5e7dfb93e62977b40493053cac85a6164cfd56686a1178df89db2081bb9a422459b66fd7596d66c9855f65c7f47f67997408917de47603f28738fbf2e26a69
|