locale_assistant 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,7 @@ def load_file(fn)
|
|
35
35
|
linecount += 1
|
36
36
|
next if line.strip.size == 0 # remove empty lines
|
37
37
|
next if line.lstrip =~ /^#/ # remove full line comments
|
38
|
+
next if line =~ /^---/ # remove hyphens
|
38
39
|
|
39
40
|
key,val = line.strip.split(/:/,2)
|
40
41
|
|
@@ -87,11 +88,13 @@ def load_file(fn)
|
|
87
88
|
return [arr,hash]
|
88
89
|
end
|
89
90
|
|
90
|
-
def write_out(fn,array,hash,country_code)
|
91
|
+
def write_out(fn,array,hash,country_code,add_hyphens)
|
91
92
|
f = File.new(fn,'w+')
|
92
93
|
prev_x = []
|
93
94
|
indent = 0
|
94
95
|
|
96
|
+
f << "--- \n" if add_hyphens
|
97
|
+
|
95
98
|
array.each do |key,val|
|
96
99
|
next if LocaleAssistant::IgnoreList.include?(key)
|
97
100
|
x = key.split('.')
|
@@ -123,7 +126,7 @@ def write_out(fn,array,hash,country_code)
|
|
123
126
|
end
|
124
127
|
end
|
125
128
|
|
126
|
-
def process_file(path,file,source,inspecting_mode,destructive,use_tempfile)
|
129
|
+
def process_file(path,file,source,inspecting_mode,destructive,use_tempfile,add_hyphens)
|
127
130
|
arrays = {}
|
128
131
|
hashes = {}
|
129
132
|
LocaleAssistant::Languages.each do |lang|
|
@@ -161,7 +164,7 @@ def process_file(path,file,source,inspecting_mode,destructive,use_tempfile)
|
|
161
164
|
file_suffix = ''
|
162
165
|
file_suffix = '.temp' if use_tempfile
|
163
166
|
|
164
|
-
write_out(path + file.gsub('#lang#',lang)+file_suffix,arrays[language_to_use],hashes[lang],lang)
|
167
|
+
write_out(path + file.gsub('#lang#',lang)+file_suffix,arrays[language_to_use],hashes[lang],lang,add_hyphens)
|
165
168
|
end
|
166
169
|
end
|
167
170
|
end
|
@@ -170,7 +173,7 @@ def parse_command_line
|
|
170
173
|
options = {}
|
171
174
|
|
172
175
|
optparse = OptionParser.new do |opts|
|
173
|
-
opts.banner = "Usage: locale_assistant
|
176
|
+
opts.banner = "Usage: locale_assistant [options] source_language"
|
174
177
|
|
175
178
|
options[:destructive] = false
|
176
179
|
opts.on( '-D', '--destructive', 'If you want to clear keys that are not in the source language' ) do
|
@@ -187,6 +190,11 @@ def parse_command_line
|
|
187
190
|
options[:inspecting_mode] = true
|
188
191
|
end
|
189
192
|
|
193
|
+
options[:add_hyphens] = false
|
194
|
+
opts.on( '-a', '--add_hyphens', 'Add "--- \n" to the beginning of every yaml file' ) do
|
195
|
+
options[:add_hyphens] = true
|
196
|
+
end
|
197
|
+
|
190
198
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
191
199
|
puts opts
|
192
200
|
exit
|
@@ -202,8 +210,8 @@ options = parse_command_line
|
|
202
210
|
if LocaleAssistant::Languages.include?(ARGV[0])
|
203
211
|
puts "using " + ARGV[0] + " as source language"
|
204
212
|
LocaleAssistant::Files.each do |file|
|
205
|
-
process_file(Dir.pwd+'/',file,ARGV[0],options[:inspecting_mode],options[:destructive],options[:tempfile])
|
213
|
+
process_file(Dir.pwd+'/',file,ARGV[0],options[:inspecting_mode],options[:destructive],options[:tempfile],options[:add_hyphens])
|
206
214
|
end
|
207
215
|
else
|
208
|
-
puts "Usage: locale_assistant
|
216
|
+
puts "Usage: locale_assistant [options] source_language"
|
209
217
|
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: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 3
|
10
|
+
version: 0.9.3
|
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-26 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -25,13 +25,13 @@ description: |-
|
|
25
25
|
if you want to keep things simple and do not need online services like localeapp
|
26
26
|
email: jsaak@email.to
|
27
27
|
executables:
|
28
|
-
- locale_assistant
|
28
|
+
- locale_assistant
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
|
33
33
|
files:
|
34
|
-
- bin/locale_assistant
|
34
|
+
- bin/locale_assistant
|
35
35
|
has_rdoc: true
|
36
36
|
homepage: https://github.com/jsaak/locale_assistant
|
37
37
|
licenses: []
|