From 0fdceca20dd5cb1913878b7148c767fdef1a477c Mon Sep 17 00:00:00 2001 From: Sebastian Ludwig Date: Sat, 5 Dec 2015 17:23:41 +0100 Subject: [PATCH] Using Android placeholder conversions in Tizen (as it did before) and removed now unused androidify_substitutions. --- lib/twine/formatters/abstract.rb | 48 -------------------------------- lib/twine/formatters/tizen.rb | 4 +-- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/lib/twine/formatters/abstract.rb b/lib/twine/formatters/abstract.rb index 4d9c361..6596dec 100644 --- a/lib/twine/formatters/abstract.rb +++ b/lib/twine/formatters/abstract.rb @@ -21,54 +21,6 @@ module Twine str.gsub!(/%([0-9\$]*)s/, '%\1@') return str end - - def androidify_substitutions(str) - # 1) use "s" instead of "@" for substituting strings - str.gsub!(/%([0-9\$]*)@/, '%\1s') - - # 1a) escape strings that begin with a lone "@" - str.sub!(/^@ /, '\\@ ') - - # 2) if there is more than one substitution in a string, make sure they are numbered - substituteCount = 0 - startFound = false - str.each_char do |c| - if startFound - if c == "%" - # ignore as this is a literal % - elsif c.match(/\d/) - # leave the string alone if it already has numbered substitutions - return str - else - substituteCount += 1 - end - startFound = false - elsif c == "%" - startFound = true - end - end - - if substituteCount > 1 - currentSub = 1 - startFound = false - newstr = "" - str.each_char do |c| - if startFound - if !(c == "%") - newstr = newstr + "#{currentSub}$" - currentSub += 1 - end - startFound = false - elsif c == "%" - startFound = true - end - newstr = newstr + c - end - return newstr - else - return str - end - end def set_translation_for_key(key, lang, value) if @strings.strings_map.include?(key) diff --git a/lib/twine/formatters/tizen.rb b/lib/twine/formatters/tizen.rb index 9453c8c..006550f 100644 --- a/lib/twine/formatters/tizen.rb +++ b/lib/twine/formatters/tizen.rb @@ -90,7 +90,7 @@ module Twine value = CGI.unescapeHTML(value) value.gsub!('\\\'', '\'') value.gsub!('\\"', '"') - value = iosify_substitutions(value) + value = Placeholders.from_android_to_twine(value) value.gsub!(/(\\u0020)*|(\\u0020)*\z/) { |spaces| ' ' * (spaces.length / 6) } else value = "" @@ -147,7 +147,7 @@ module Twine # 2) HTML escape the string value = CGI.escapeHTML(value) # 3) fix substitutions (e.g. %s/%@) - value = androidify_substitutions(value) + value = Placeholders.from_twine_to_android(value) # 4) replace beginning and end spaces with \0020. Otherwise Tizen strips them. value.gsub(/\A *| *\z/) { |spaces| '\u0020' * spaces.length } end