Enable test. Add wait timeout.
[cyberduck.git] / convertstrings.rb
blob3d84ad517d1430ab86da84b05420afb8f8ab01d1
1 #!/usr/bin/ruby
2 # encoding: UTF-8
4 base_language_hash = Hash::new
5 target_language_hash = Hash::new
6 comment_hash = Hash::new
8 # Open base language
9 open($*[0], "rb:UTF-16LE:UTF-8") do |f|
10   f.each { |line|
11     pattern = '^"(\d*)\..*" = "(.*)";$'
12     r = Regexp.new(pattern, Regexp::FIXEDENCODING)
13     r.match(line) { |m|
14       key = m[1]
15       base_language_hash.store(key, m[2])
16     }
17   }
18 end
19 # Open target language
20 open($*[1], "rb:UTF-16LE:UTF-8") do |f|
21   f.each { |line|
22     pattern = '^\/\* Class = "(.*)"; .* = "(.*)"; ObjectID = "(.*)"; \*\/$'
23     r = Regexp.new(pattern, Regexp::FIXEDENCODING)
24     r.match(line) { |m|
25       key = m[3]
26       translation = m[2]
27       unless translation.strip.length == 0 or base_language_hash[key].eql?("OtherViews")
28         target_language_hash.store(key, translation)
29         comment_hash.store(key, "/* %s (%s) : <title:%s> (oid:%s) */" % [m[1], translation, translation, key])
30       end
31     }
32   }
33 end
35 # Write Byte Order Mark
36 print "\uFEFF".encode("UTF-16LE")
38 target_language_hash.each { |key, value|
39   comment = comment_hash[key]
40   base = base_language_hash[key]
41   output = "%s\n\"%s\" = \"%s\";\n\n" % [comment, base, value]
42   print output.encode("UTF-16LE")