Encode length and punctuation in key IDs

This is to ensure we don't end up using the same string for two
strings using the same words but different length and punctuation.
This commit is contained in:
djoate 2019-11-25 20:53:59 -05:00
parent ab689944d6
commit f78c9e11bb
No known key found for this signature in database
GPG Key ID: E8366E2E207EFB0E
2 changed files with 2069 additions and 1928 deletions

View File

@ -21,8 +21,11 @@ module Weblate
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(' ', '_') << "_KEY"
.gsub(/([^\w\d\s\.\?\!]|\n)/, '')
.tr(' ', '_')
.tr('.', 'P')
.tr('?', 'Q')
.tr('!', 'E') << "_" << source_text.length.to_s << "_KEY"
end
end

File diff suppressed because it is too large Load Diff