Actions
Bug #1733
closedxmera Omnia - Feature #1736: Support float custom fields to accept user input values considering language conventions
Allow to add and display floating numbers in accordance with the users language
Start date:
Due date:
% Done:
100%
Estimated time:
Affected Version:
Compatible Redmine Version:
Pull Request Link:
Description
Redmine 5.0.5: Custom field format 'Float' does not support values inserted in the users language, e.g., 1,22
instead of 1.22
.
# lib/redmine/field_format.rb:539
def validate_single_value(custom_field, value, customized=nil)
errs = super
errs << ::I18n.t('activerecord.errors.messages.invalid') unless (Kernel.Float(value) rescue nil) # <-- Kernle.Float(value) accepts only 1.22!
errs
end
The values needs to be normalized into the accepted format before it will get validated. The method could look something like this:
def normalize_float(value)
delimiter = I18n::t('number.format.delimiter')
separator = I18n::t('number.format.separator')
value.gsub!(/[#{delimiter}#{separator}]/, delimiter => '', separator => '.')
end
Files
Updated by liaham over 1 year ago
- Subject changed from Allow to add floating numbers in accordance with the users language to Allow to add and display floating numbers in accordance with the users language
Updated by liaham over 1 year ago
There are already some issues on redmine:
- https://www.redmine.org/issues/21677
- https://www.redmine.org/issues/22024
- https://www.redmine.org/issues/25012
- https://www.redmine.org/issues/36183
Rails helpers:
Updated by liaham over 1 year ago
- Status changed from New to Closed
- Assignee set to liaham
- % Done changed from 0 to 100
See redmine.org issue #22024.
Integrated as patch file.
Updated by liaham over 1 year ago
- File support-localized-decimal-separator_5.0.6.patch support-localized-decimal-separator_5.0.6.patch added
The patch has changed! It is not yet commited to redmine.org.
Actions