Feature #21677 » 21677-localised_decimals_in_web.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
| 422 | 422 |
end |
| 423 | 423 | |
| 424 | 424 |
def html_hours(text) |
| 425 |
text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>').html_safe
|
|
| 425 |
hours_int_sep_dec = Regexp.new("(\\d+)([\\.#{Regexp.escape l(:general_csv_decimal_separator)}])(\\d+)")
|
|
| 426 |
text.gsub(hours_int_sep_dec, '<span class="hours hours-int">\1</span><span class="hours hours-dec">\2\3</span>').html_safe |
|
| 426 | 427 |
end |
| 427 | 428 | |
| 428 | 429 |
def authoring(created, author, options={})
|
| app/helpers/queries_helper.rb | ||
|---|---|---|
| 150 | 150 |
content_tag('span',
|
| 151 | 151 |
value.to_s(issue) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
|
| 152 | 152 |
:class => value.css_classes_for(issue)) |
| 153 |
when :hours, :total_spent_hours, :estimated_hours |
|
| 154 |
l_number("%.2f", value)
|
|
| 153 | 155 |
else |
| 154 | 156 |
format_object(value) |
| 155 | 157 |
end |
| ... | ... | |
| 168 | 170 |
format_object(value, false) do |value| |
| 169 | 171 |
case value.class.name |
| 170 | 172 |
when 'Float' |
| 171 |
sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
|
|
| 173 |
l_number("%.2f", value)
|
|
| 172 | 174 |
when 'IssueRelation' |
| 173 | 175 |
value.to_s(object) |
| 174 | 176 |
when 'Issue' |
| app/views/my/blocks/_timelog.html.erb | ||
|---|---|---|
| 14 | 14 |
<% end %> |
| 15 | 15 | |
| 16 | 16 |
<div class="total-hours"> |
| 17 |
<p><%= l(:label_total_time) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
|
|
| 17 |
<p><%= l(:label_total_time) %>: <%= html_hours(l_number("%.2f", entries.sum(&:hours).to_f)) %></p>
|
|
| 18 | 18 |
</div> |
| 19 | 19 | |
| 20 | 20 |
<% if entries.any? %> |
| ... | ... | |
| 31 | 31 |
<tr class="odd"> |
| 32 | 32 |
<td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td> |
| 33 | 33 |
<td colspan="2"></td> |
| 34 |
<td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
|
|
| 34 |
<td class="hours"><em><%= html_hours(l_number("%.2f", entries_by_day[day].sum(&:hours).to_f)) %></em></td>
|
|
| 35 | 35 |
<td></td> |
| 36 | 36 |
</tr> |
| 37 | 37 |
<% entries_by_day[day].each do |entry| -%> |
| ... | ... | |
| 39 | 39 |
<td class="activity"><%= entry.activity %></td> |
| 40 | 40 |
<td class="subject"><%= entry.project %> <%= h(' - ') + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
|
| 41 | 41 |
<td class="comments"><%= entry.comments %></td> |
| 42 |
<td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
|
|
| 42 |
<td class="hours"><%= html_hours(l_number("%.2f", entry.hours)) %></td>
|
|
| 43 | 43 |
<td class="buttons"> |
| 44 | 44 |
<% if entry.editable_by?(@user) -%> |
| 45 | 45 |
<%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
|
| app/views/timelog/_report_criteria.html.erb | ||
|---|---|---|
| 8 | 8 |
<% total = 0 -%> |
| 9 | 9 |
<% @report.periods.each do |period| -%> |
| 10 | 10 |
<% sum = sum_hours(select_hours(hours_for_value, @report.columns, period.to_s)); total += sum -%> |
| 11 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
|
|
| 11 |
<td class="hours"><%= html_hours(l_number("%.2f", sum)) if sum > 0 %></td>
|
|
| 12 | 12 |
<% end -%> |
| 13 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
|
| 13 |
<td class="hours"><%= html_hours(l_number("%.2f", total)) if total > 0 %></td>
|
|
| 14 | 14 |
</tr> |
| 15 | 15 |
<% if criterias.length > level+1 -%> |
| 16 | 16 |
<%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :hours => hours_for_value, :level => (level + 1)}) %>
|
| app/views/timelog/report.html.erb | ||
|---|---|---|
| 56 | 56 |
<% total = 0 -%> |
| 57 | 57 |
<% @report.periods.each do |period| -%> |
| 58 | 58 |
<% sum = sum_hours(select_hours(@report.hours, @report.columns, period.to_s)); total += sum -%> |
| 59 |
<td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
|
|
| 59 |
<td class="hours"><%= html_hours(l_number("%.2f", sum)) if sum > 0 %></td>
|
|
| 60 | 60 |
<% end -%> |
| 61 |
<td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
|
|
| 61 |
<td class="hours"><%= html_hours(l_number("%.2f", total)) if total > 0 %></td>
|
|
| 62 | 62 |
</tr> |
| 63 | 63 |
</tbody> |
| 64 | 64 |
</table> |
| lib/redmine/i18n.rb | ||
|---|---|---|
| 45 | 45 | |
| 46 | 46 |
def l_hours(hours) |
| 47 | 47 |
hours = hours.to_f |
| 48 |
l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => ("%.2f" % hours.to_f))
|
|
| 48 |
l((hours < 2.0 ? :label_f_hour : :label_f_hour_plural), :value => l_number("%.2f", hours.to_f))
|
|
| 49 |
end |
|
| 50 | ||
| 51 |
def l_number(format, value) |
|
| 52 |
return '' if value.blank? |
|
| 53 |
sprintf(format, value).gsub('.', l(:general_csv_decimal_separator))
|
|
| 49 | 54 |
end |
| 50 | 55 | |
| 51 | 56 |
def l_hours_short(hours) |