diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2012-09-26 15:25:59 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:57 +0300 |
commit | b9430b0a04fbc7f53c1ed9e1477dbc1f0c45f0a6 (patch) | |
tree | 5682c604daf14dcae7ad9df885d23ad05e645003 /tools | |
parent | ceb3ed16fbb51c13fc93eca492bf28f8f250524f (diff) |
Updated Twine tool to 0.3.2
Diffstat (limited to 'tools')
-rw-r--r-- | tools/twine/lib/twine/formatters/android.rb | 13 | ||||
-rw-r--r-- | tools/twine/lib/twine/version.rb | 2 | ||||
-rw-r--r-- | tools/twine/test/fixtures/test-output-1.txt | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/tools/twine/lib/twine/formatters/android.rb b/tools/twine/lib/twine/formatters/android.rb index b0f0125bb3..68332707ee 100644 --- a/tools/twine/lib/twine/formatters/android.rb +++ b/tools/twine/lib/twine/formatters/android.rb @@ -1,5 +1,5 @@ # encoding: utf-8 - +require 'CGI' require 'rexml/document' module Twine @@ -67,6 +67,8 @@ module Twine value_match = value_regex.match(line) if value_match value = value_match[1] + value = CGI.unescapeHTML(value) + value.gsub!('\\\'', '\'') value.gsub!('\\"', '"') value = iosify_substitutions(value) else @@ -76,7 +78,7 @@ module Twine set_tags_for_key(key, @options[:tags]) end set_translation_for_key(key, lang, value) - if comment and comment.length > 0 + if comment and comment.length > 0 and !comment.start_with?("SECTION:") set_comment_for_key(key, comment) end comment = nil @@ -107,7 +109,7 @@ module Twine f.puts '' if section.name && section.name.length > 0 section_name = section.name.gsub('--', '—') - f.puts "\t<!-- #{section_name} -->" + f.puts "\t<!-- SECTION: #{section_name} -->" end printed_section = true end @@ -126,9 +128,8 @@ module Twine # 1) apostrophes and quotes must be escaped with a backslash value.gsub!('\'', '\\\\\'') value.gsub!('"', '\\\\"') - # 2) ampersand and less-than must be in XML-escaped form - value.gsub!('&', '&') - value.gsub!('<', '<') + # 2) HTML escape the string + value = CGI.escapeHTML(value) # 3) fix substitutions (e.g. %s/%@) value = androidify_substitutions(value) diff --git a/tools/twine/lib/twine/version.rb b/tools/twine/lib/twine/version.rb index fe9ab016be..30ccb50b15 100644 --- a/tools/twine/lib/twine/version.rb +++ b/tools/twine/lib/twine/version.rb @@ -1,3 +1,3 @@ module Twine - VERSION = '0.3.1' + VERSION = '0.3.2' end diff --git a/tools/twine/test/fixtures/test-output-1.txt b/tools/twine/test/fixtures/test-output-1.txt index 2c2a810ef6..e7000f5330 100644 --- a/tools/twine/test/fixtures/test-output-1.txt +++ b/tools/twine/test/fixtures/test-output-1.txt @@ -3,7 +3,7 @@ <!-- Generated by Twine <%= Twine::VERSION %> --> <!-- Language: fr --> <resources> - <!-- My Strings --> + <!-- SECTION: My Strings --> <!-- This is a comment --> <string name="key1">key1-french</string> <string name="key2">key2-french</string> |