4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/models/concerns/localize_input.rb', line 4
def self.parse(input)
return input unless input.is_a? String
Rails.logger.debug { "Input: #{input.inspect}" }
separator = I18n.t('separator', 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+/) input.gsub!(separator, '.') input
rescue StandardError
Rails.logger.warn "Can't localize input: #{input}"
input
end
|