class Translatomatic::ResourceFile::RESW
Windows resources file (XML
)
Public Class Methods
extensions()
click to toggle source
(see Base.extensions
)
# File lib/translatomatic/resource_file/resw.rb, line 6 def self.extensions %w[resw resx] end
key_value?()
click to toggle source
(see Base.key_value?
)
# File lib/translatomatic/resource_file/resw.rb, line 11 def self.key_value? true end
Private Instance Methods
create_node(key, value)
click to toggle source
# File lib/translatomatic/resource_file/resw.rb, line 50 def create_node(key, value) # add xml: <data name="key"><value>value</value></data> data_node = Nokogiri::XML::Node.new('data', @doc) data_node['name'] = key value_node = Nokogiri::XML::Node.new('value', @doc) text_node = Nokogiri::XML::Text.new(value.to_s, @doc) value_node.add_child(text_node) data_node.add_child(value_node) @doc.root.add_child(data_node) @nodemap[key] = text_node @properties[key] = value end
found_value(value)
click to toggle source
# File lib/translatomatic/resource_file/resw.rb, line 44 def found_value(value) @nodemap[@key] = value if @key @metadata.assign_key(@key) @key = nil end
init_nodemap()
click to toggle source
# File lib/translatomatic/resource_file/resw.rb, line 17 def init_nodemap @nodemap = {} nodes = @doc.search('//data/@name|//text()|//comment()') nodes.each do |node| process_node(node) end end
process_node(node)
click to toggle source
# File lib/translatomatic/resource_file/resw.rb, line 25 def process_node(node) if node.comment? @metadata.parse_comment(node.content) elsif node.type == Nokogiri::XML::Node::ATTRIBUTE_NODE # data name="" @key = node.content elsif node.text? process_text_node(node) end end
process_text_node(node)
click to toggle source
# File lib/translatomatic/resource_file/resw.rb, line 35 def process_text_node(node) parent = node.parent if parent.name == 'value' # <value>content</value> found_value(node) elsif parent.name == 'comment' @metadata.parse_comment(node.content) end end