From 8b5226d388182d48deee4f0a8aba3c221d05aad1 Mon Sep 17 00:00:00 2001 From: djoate <56777051+djoate@users.noreply.github.com> Date: Sun, 24 Nov 2019 13:01:04 -0500 Subject: [PATCH] Append _KEY to keys and strip newlines from ID Some strings such as "Yes" and "No" refuse to be translated, so we need to pad the IDs somehow. --- _plugins/weblate-source-file.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_plugins/weblate-source-file.rb b/_plugins/weblate-source-file.rb index 791b4bb0..17c7759e 100644 --- a/_plugins/weblate-source-file.rb +++ b/_plugins/weblate-source-file.rb @@ -19,8 +19,10 @@ module Weblate class ID def self.get(source_text) - source_text.nil? ? source_text - : source_text.strip[0..100].gsub(/[^\w\d\s\.\?\!]/, '').tr(' ', '_') + source_text.nil? or source_text.empty? ? source_text + : source_text.strip[0..100] + .gsub(/([^\w\d\s\.\?\!]|\n)/, '') + .tr(' ', '_') << "_KEY" end end