diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index f152e21..8586483 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -422,7 +422,8 @@ module ApplicationHelper
end
def html_hours(text)
- text.gsub(%r{(\d+)\.(\d+)}, '\1.\2').html_safe
+ hours_int_sep_dec = Regexp.new("(\\d+)([\\.#{Regexp.escape l(:general_csv_decimal_separator)}])(\\d+)")
+ text.gsub(hours_int_sep_dec, '\1\2\3').html_safe
end
def authoring(created, author, options={})
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 9ad2540..7a81a2c 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -150,6 +150,8 @@ module QueriesHelper
content_tag('span',
value.to_s(issue) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
:class => value.css_classes_for(issue))
+ when :hours, :total_spent_hours, :estimated_hours
+ l_number("%.2f", value)
else
format_object(value)
end
@@ -168,7 +170,7 @@ module QueriesHelper
format_object(value, false) do |value|
case value.class.name
when 'Float'
- sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
+ l_number("%.2f", value)
when 'IssueRelation'
value.to_s(object)
when 'Issue'
diff --git a/app/views/my/blocks/_timelog.html.erb b/app/views/my/blocks/_timelog.html.erb
index 747039c..99eda59 100644
--- a/app/views/my/blocks/_timelog.html.erb
+++ b/app/views/my/blocks/_timelog.html.erb
@@ -14,7 +14,7 @@ entries_by_day = entries.group_by(&:spent_on)
<% end %>
-
<%= l(:label_total_time) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %>
+
<%= l(:label_total_time) %>: <%= html_hours(l_number("%.2f", entries.sum(&:hours).to_f)) %>
<% if entries.any? %>
@@ -31,7 +31,7 @@ entries_by_day = entries.group_by(&:spent_on)
<%= day == Date.today ? l(:label_today).titleize : format_date(day) %> |
|
- <%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %> |
+ <%= html_hours(l_number("%.2f", entries_by_day[day].sum(&:hours).to_f)) %> |
|
<% entries_by_day[day].each do |entry| -%>
@@ -39,7 +39,7 @@ entries_by_day = entries.group_by(&:spent_on)
<%= entry.activity %> |
<%= entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %> |
- <%= html_hours("%.2f" % entry.hours) %> |
+ <%= html_hours(l_number("%.2f", entry.hours)) %> |
<% if entry.editable_by?(@user) -%>
<%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
diff --git a/app/views/timelog/_report_criteria.html.erb b/app/views/timelog/_report_criteria.html.erb
index c86b219..5931e9e 100644
--- a/app/views/timelog/_report_criteria.html.erb
+++ b/app/views/timelog/_report_criteria.html.erb
@@ -8,9 +8,9 @@
<% total = 0 -%>
<% @report.periods.each do |period| -%>
<% sum = sum_hours(select_hours(hours_for_value, @report.columns, period.to_s)); total += sum -%>
- | <%= html_hours("%.2f" % sum) if sum > 0 %> |
+ <%= html_hours(l_number("%.2f", sum)) if sum > 0 %> |
<% end -%>
- <%= html_hours("%.2f" % total) if total > 0 %> |
+ <%= html_hours(l_number("%.2f", total)) if total > 0 %> |
<% if criterias.length > level+1 -%>
<%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :hours => hours_for_value, :level => (level + 1)}) %>
diff --git a/app/views/timelog/report.html.erb b/app/views/timelog/report.html.erb
index 176f128..91c69a5 100644
--- a/app/views/timelog/report.html.erb
+++ b/app/views/timelog/report.html.erb
@@ -56,9 +56,9 @@
<% total = 0 -%>
<% @report.periods.each do |period| -%>
<% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%>
- <%= html_hours("%.2f" % sum) if sum > 0 %> |
+ <%= html_hours(l_number("%.2f", sum)) if sum > 0 %> |
<% end -%>
- <%= html_hours("%.2f" % total) if total > 0 %> |
+ <%= html_hours(l_number("%.2f", total)) if total > 0 %> |
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index 9523f23..b429133 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -45,7 +45,12 @@ module Redmine
def l_hours(hours)
hours = hours.to_f
- l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
+ l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => l_number("%.2f", hours.to_f))
+ end
+
+ def l_number(format, value)
+ return '' if value.blank?
+ sprintf(format, value).gsub('.', l(:general_csv_decimal_separator))
end
def l_hours_short(hours)