2 # po2yaml, for converting gettext .po to the RoR translation YAML
 
   4 #  - To create a language's yaml from a given po file
 
   5 #    po2yaml de.po > de.yml
 
   9 def add_translation(hash, keys, value)
 
  14     unless hash.has_key? key
 
  17     add_translation(hash[key], keys, value)
 
  28     if line[0..8] == 'msgctxt "'
 
  29       path = line[9..-2].split(':')
 
  30     elsif line[0..7] == 'msgstr "'
 
  34     if !path.empty? and !msgstr.empty?
 
  35       add_translation(trs, path, msgstr)
 
  44 pofile = File.open(filename, "r")
 
  46 langcode = File.basename(filename, '.po')
 
  48 tr = {langcode => po2hash(pofile)}