diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index dcf1da35b..a82163b76 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -684,7 +684,7 @@ module ApplicationHelper
def html_hours(text)
text.gsub(
- %r{(\d+)([\.:])(\d+)},
+ %r{(\d+)([\.,:])(\d+)},
'\1\2\3'
).html_safe
end
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index dab486893..6c4d2aad7 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -21,6 +21,8 @@ require 'redmine'
module Redmine
module I18n
+ include ActionView::Helpers::NumberHelper
+
def self.included(base)
base.extend Redmine::I18n
end
@@ -95,7 +97,7 @@ module Redmine
m = ((hours - h) * 60).round
"%d:%02d" % [h, m]
else
- "%.2f" % hours.to_f
+ number_with_delimiter(sprintf('%.2f', hours.to_f), delimiter: nil)
end
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 8dccb8b7e..82b1c3278 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -2171,6 +2171,17 @@ class ApplicationHelperTest < Redmine::HelperTest
end
end
+ def test_format_hours_should_use_locale_decimal_separator
+ to_test = {'en' => '0.75', 'de' => '0,75'}
+ with_settings :timespan_format => 'decimal' do
+ to_test.each do |locale, expected|
+ with_locale locale do
+ assert_equal expected, format_hours(0.75)
+ end
+ end
+ end
+ end
+
def test_html_hours
assert_equal '0:45',
html_hours('0:45')