Class: Babelish::Android2CSV

Inherits:
Base2Csv show all
Defined in:
lib/babelish/android2csv.rb

Instance Attribute Summary

Attributes inherited from Base2Csv

#csv_filename, #default_lang, #filenames, #headers

Instance Method Summary collapse

Methods inherited from Base2Csv

#convert

Constructor Details

#initialize(args = {:filenames => []}) ⇒ Android2CSV

Returns a new instance of Android2CSV.



5
6
7
# File 'lib/babelish/android2csv.rb', line 5

def initialize(args = {:filenames => []})
  super(args)
end

Instance Method Details

#load_strings(strings_filename) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/babelish/android2csv.rb', line 9

def load_strings(strings_filename)
  strings = {}
  xml_file = File.open(strings_filename)

  parser = Nokogiri::XML(xml_file) do |config|
    config.strict.noent
  end
  parser.xpath("//string").each do |node|
    if !node.nil? && !node["name"].nil?
      strings.merge!(node["name"] => node.inner_html)
    end
  end

  xml_file.close

  [strings, {}]
end