class Locca::AndroidStringsParser
Public Class Methods
new()
click to toggle source
# File lib/locca/android_strings_parser.rb, line 31 def initialize() end
Public Instance Methods
parse(str, &block)
click to toggle source
# File lib/locca/android_strings_parser.rb, line 35 def parse(str, &block) doc = Nokogiri::XML(str) comment = nil for node in doc.root.children if node.comment? comment = node.text.strip elsif node.element? if node.name == "string" block.call(node["name"], node.text, comment) comment = nil elsif node.name == "plurals" values = Hash.new() for pluralItem in node.xpath('.//item') values[pluralItem["quantity"]] = pluralItem.text end block.call(node["name"], values, comment) comment = nil end end end end