Cleanup section headers in generated string files.

This commit is contained in:
Sebastian Celis 2012-02-06 14:38:50 -06:00
parent 8188d16b86
commit 681dc84bec
2 changed files with 20 additions and 10 deletions

View file

@ -53,18 +53,20 @@ module Twine
default_lang = strings.language_codes[0]
File.open(path, 'w:UTF-8') do |f|
f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Android Strings File -->\n<!-- Generated by Twine -->\n<!-- Language: #{lang} -->"
f.puts '<resources>'
section_num = -1
f.write '<resources>'
strings.sections.each do |section|
section_num += 1
if section_num > 0
f.puts ''
end
section_name = section.name.gsub('--', '—')
f.puts "\t<!-- #{section_name} -->"
printed_section = false
section.rows.each do |row|
if row_matches_tags?(row, tags)
unless printed_section
f.puts ''
if section.name && section.name.length > 0
section_name = section.name.gsub('--', '—')
f.puts "\t<!-- #{section_name} -->"
end
printed_section = true
end
key = row.key
key = CGI.escapeHTML(key)

View file

@ -49,9 +49,17 @@ module Twine
File.open(path, 'w:UTF-8') do |f|
f.puts "/**\n * iOS Strings File\n * Generated by Twine\n * Language: #{lang}\n */"
strings.sections.each do |section|
f.puts "\n/* #{section.name} */"
printed_section = false
section.rows.each do |row|
if row_matches_tags?(row, tags)
unless printed_section
f.puts ''
if section.name && section.name.length > 0
f.puts "/* #{section.name} */"
end
printed_section = true
end
key = row.key
key = key.gsub('"', '\\\\"')