i18n: Encode string lengths after strip #1535

Open
djoate wants to merge 1 commits from djoate/i18n-encode-len-after-strip into i18n-simple
2 changed files with 1301 additions and 1412 deletions

View File

@ -19,13 +19,16 @@ module Weblate
class ID
def self.get(source_text)
source_text.nil? or source_text.empty? ? source_text
: source_text.strip[0..150]
.gsub(/([^\w\d\s\.\?\!]|\n)/, '')
.tr(' ', '_')
.tr('.', 'P')
.tr('?', 'Q')
.tr('!', 'E') << "_" << source_text.length.to_s << "_KEY"
if source_text.nil? or source_text.empty?
source_text
else
len_encoding = source_text.strip.length.to_s
source_text.strip[0..150].gsub(/([^\w\d\s\.\?\!]|\n)/, '')
.tr(' ', '_')
.tr('.', 'P')
.tr('?', 'Q')
.tr('!', 'E') << "_" << len_encoding << "_KEY"
end
end
end

File diff suppressed because it is too large Load Diff