adapt localize input to remove ',' separator and replace with '.'

This commit is contained in:
viehlieb 2023-02-07 17:05:16 +01:00
parent c8354c76ff
commit 068e5cb776

View file

@ -8,7 +8,7 @@ module LocalizeInput
separator = I18n.t("separator", scope: "number.format") separator = I18n.t("separator", scope: "number.format")
delimiter = I18n.t("delimiter", scope: "number.format") delimiter = I18n.t("delimiter", scope: "number.format")
input.gsub!(delimiter, "") if input.match(/\d+#{Regexp.escape(delimiter)}+\d+#{Regexp.escape(separator)}+\d+/) # Remove delimiter input.gsub!(delimiter, "") if input.match(/\d+#{Regexp.escape(delimiter)}+\d+#{Regexp.escape(separator)}+\d+/) # Remove delimiter
input.gsub!(separator, ".") # Replace separator with db compatible character input.gsub!(separator, ".") or input.gsub!(",", ".") # Replace separator with db compatible character
input input
rescue rescue
Rails.logger.warn "Can't localize input: #{input}" Rails.logger.warn "Can't localize input: #{input}"