Class: Locca::AndroidStringsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/locca/android_strings_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeAndroidStringsParser

Returns a new instance of AndroidStringsParser.



31
32
33
# File 'lib/locca/android_strings_parser.rb', line 31

def initialize()
	
end

Instance Method Details

#parse(str, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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