Encode string lengths after strip

This commit is contained in:
djoate 2019-11-28 02:27:15 -05:00
parent e14bcae99c
commit 450d73065a
No known key found for this signature in database
GPG Key ID: E8366E2E207EFB0E
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