--- /dev/null
+#!/usr/bin/ruby
+class PoStr
+ Sections = %w(Headers Source Translated)
+ attr_accessor :status, :src, :dest, :type, :location
+ def initialize(text)
+ section = 0
+ @status = ''
+ @src = []
+ @dest = []
+
+ text.split(/\n/).each do |lin|
+ # Header
+ if section == 0
+ if lin =~ /^#(.) ([^:]*)(?::(.*))?/
+ type = $1
+ field = $2
+ value = $3
+
+ @status = 'fuzzy' if type == ',' and field == 'fuzzy'
+ @type = value if type == '.' and field == 'type'
+ @location = {:file => field, :line => value} if type == ':'
+ elsif lin =~ /^msgid (".*")/
+ section += 1
+ @src << $1
+ else
+ boom(section, lin, text)
+ end
+
+ # Source text
+ elsif section == 1
+ if lin =~ /^".*"$/
+ @src << lin
+ elsif lin =~ /^msgstr (".*")/
+ section += 1
+ @dest << $1
+ else
+ boom(section, lin, text)
+ end
+
+ # Translated text
+ else
+ if lin =~ /^".*"$/
+ @dest << lin
+ else
+ boom(section, lin, text)
+ end
+ end
+ end
+ end
+
+ def boom(section, line, text)
+ raise RuntimeError, "Unexpected string in %s:\n %s\n\nFull text: %s" %
+ [Sections[section], line, text]
+ end
+
+ def fuzzy?
+ @status == 'fuzzy'
+ end
+end
+
+file = 'po/es/mwcc.po'
+strings = File.open(file,'r').read.split(/\n\n/)[1..-1].map {|str| PoStr.new(str)}