Using Android placeholder conversions in Tizen (as it did before) and removed now unused androidify_substitutions.
This commit is contained in:
parent
d21f07e735
commit
0fdceca20d
2 changed files with 2 additions and 50 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue