locale_assistant 0.9.0 → 0.9.1
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.
- data/bin/locale_assistant.rb +39 -30
- metadata +4 -4
data/bin/locale_assistant.rb
CHANGED
@@ -17,6 +17,7 @@ module LocaleAssistant
|
|
17
17
|
IgnoreList = []
|
18
18
|
end
|
19
19
|
|
|
20
|
+
exit
|
20
21
|
end
|
21
22
|
|
22
23
|
def load_file(fn)
|
@@ -27,38 +28,46 @@ def load_file(fn)
|
|
27
28
|
indentstore = []
|
28
29
|
spaces = -1
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
31
|
+
begin
|
32
|
+
f = File.open(fn)
|
33
|
+
f.each_line do |line|
|
34
|
+
next if line.strip.size == 0 # remove empty lines
|
35
|
+
next if line.lstrip =~ /^#/ # remove full line comments
|
36
|
+
|
37
|
+
curr_spaces = (line.size - line.lstrip.size)
|
38
|
+
key,val = line.strip.split(/:/,2)
|
39
|
+
val = val.strip
|
40
|
+
|
41
|
+
val = '' if val =~ /^#/ # remove comments from non leaf elements
|
42
|
+
|
43
|
+
if curr_spaces > spaces
|
44
|
+
indentstore.push(curr_spaces-spaces)
|
45
|
+
spaces = curr_spaces
|
46
|
+
keystore.push(key)
|
47
|
+
elsif curr_spaces == spaces
|
47
48
|
keystore.pop
|
49
|
+
keystore.push(key)
|
50
|
+
elsif curr_spaces < spaces
|
51
|
+
keystore.pop
|
52
|
+
while curr_spaces < spaces
|
53
|
+
spaces -= indentstore.pop
|
54
|
+
keystore.pop
|
55
|
+
end
|
56
|
+
keystore.push(key)
|
48
57
|
end
|
49
|
-
keystore.push(key)
|
50
|
-
end
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
unless val == ''
|
60
|
+
x = keystore.join('.')
|
61
|
+
hash[x] = val
|
62
|
+
arr.push([x,val])
|
63
|
+
end
|
56
64
|
end
|
65
|
+
f.close
|
57
66
|
|
67
|
+
arr.sort!
|
68
|
+
rescue Errno::ENOENT
|
58
69
|
end
|
59
|
-
f.close
|
60
70
|
|
61
|
-
arr.sort!
|
62
71
|
return [arr,hash]
|
63
72
|
end
|
64
73
|
|
@@ -85,9 +94,9 @@ def write_out(fn,array,hash,country_code)
|
|
85
94
|
if indent+1 == x[counter..-1].size
|
86
95
|
value2 = hash[country_code+key[2..-1]]
|
87
96
|
if value2.nil?
|
88
|
-
f << '
|
97
|
+
f << val.gsub(/^(['"]?)/,' \1TODO ')
|
89
98
|
else
|
90
|
-
f << '
|
99
|
+
f << ' ' + value2.to_s
|
91
100
|
end
|
92
101
|
end
|
93
102
|
f << "\n"
|
@@ -113,7 +122,7 @@ def process_file(path,file,source,inspecting_mode,destructive,use_tempfile)
|
|
113
122
|
if LocaleAssistant::IgnoreList.include?(localized_key)
|
114
123
|
#puts fn_beg+lang+fn_end + ' ignoring:' + localized_key
|
115
124
|
else
|
116
|
-
arrays[lang] << [localized_key,
|
125
|
+
arrays[lang] << [localized_key,val]
|
117
126
|
puts file.gsub('#lang#',lang) + ' MISSING: ' + localized_key
|
118
127
|
end
|
119
128
|
end
|
@@ -145,7 +154,7 @@ def parse_command_line
|
|
145
154
|
options = {}
|
146
155
|
|
147
156
|
optparse = OptionParser.new do |opts|
|
148
|
-
opts.banner = "Usage:
|
157
|
+
opts.banner = "Usage: locale_assistant.rb [options] source_language"
|
149
158
|
|
150
159
|
options[:destructive] = false
|
151
160
|
opts.on( '-D', '--destructive', 'If you want to clear keys that are not in the source language' ) do
|
@@ -180,5 +189,5 @@ if LocaleAssistant::Languages.include?(ARGV[0])
|
|
180
189
|
process_file(Dir.pwd+'/',file,ARGV[0],options[:inspecting_mode],options[:destructive],options[:tempfile])
|
181
190
|
end
|
182
191
|
else
|
183
|
-
puts "Usage:
|
192
|
+
puts "Usage: locale_assistant.rb [options] source_language"
|
184
193
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locale_assistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- jsaak
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-03-
|
18
|
+
date: 2013-03-21 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|