Platinum Partner

Ruby XML I18n File Parser

// Ruby script to help parse a XML file


require 'rexml/document'
include REXML
englishFile = File.new('englishFileName', 'w+')
spanishFile = File.new('spanishFileName', 'w+')
portugueseFile = File.new('portugueseFileName', 'w+')
errorMessagesFile = File.new("errorMessages.xml")
document = Document.new(file)
root = document.root
root.each_element("Property") do |propertyTag|
  id = propertyTag.attributes['id']   
  propertyTag.each_element("element") do |elementTag|
	  elementAttr = elementTag.attributes['otherTag']
	  error = elementTag.text == nil ? "" : "#{id} = #{elementTag.text}\n"
	  if elementAttr = "pt"
		  portugueseFile << error
	  elsif elementAttr == "es"
		  spanishFile << error
	  else 
		  portugueseFile << error
	  end
  end
end
errorMessagesFile.close()
englishFile.close()
spanishFile.close()
portugueseFile.close()
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}