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.
Files changed (2) hide show
  1. data/bin/locale_assistant.rb +39 -30
  2. metadata +4 -4
@@ -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
- f = File.open(fn)
31
- f.each_line do |line|
32
- curr_spaces = (line.size - line.lstrip.size)
33
- key,val = line.strip.split(/:/,2)
34
- val = val.strip
35
-
36
- if curr_spaces > spaces
37
- indentstore.push(curr_spaces-spaces)
38
- spaces = curr_spaces
39
- keystore.push(key)
40
- elsif curr_spaces == spaces
41
- keystore.pop
42
- keystore.push(key)
43
- elsif curr_spaces < spaces
44
- keystore.pop
45
- while curr_spaces < spaces
46
- spaces -= indentstore.pop
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
- unless val == ''
53
- x = keystore.join('.')
54
- hash[x] = val
55
- arr.push([x,val])
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 << ' "TODO ('+val.to_s+')"'
97
+ f << val.gsub(/^(['"]?)/,' \1TODO ')
89
98
  else
90
- f << ' "' + value2.to_s + '"'
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,'??? '+val.to_s]
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: #{__FILE__} [options] source_language"
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: #{__FILE__} [options] source_language"
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: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 0
10
- version: 0.9.0
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-04 00:00:00 +01:00
18
+ date: 2013-03-21 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21