class Xlocalize::Importer

Public Instance Methods

strings_content_from_translations_hash(translations_hash) click to toggle source
# File lib/xlocalize/importer.rb, line 5
def strings_content_from_translations_hash(translations_hash)
  result = StringIO.new
  translations_hash.each do |key, translations|
    translations.each do |target, note|
      result << "/* #{note} */\n" if note.length > 0
      result << "\"#{key}\" = #{target.inspect};\n\n"
    end
  end
  return result.string
end
translate_from_node(translations, node) click to toggle source
# File lib/xlocalize/importer.rb, line 16
def translate_from_node(translations, node)
  (node > "body > trans-unit").each do |trans_unit|
    key = trans_unit["id"]
    target = (trans_unit > "target").text
    note = (trans_unit > "note").text
    if translations.key?(key)
      translations[key] = { target => note }
    end
  end
end