From 0be401391901f0d6e1808c706f76d9c2cca3c0cf Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 4 Jan 2024 07:04:00 +0000 Subject: [PATCH] Support localized decimal separators for float values in PDF export (#22024). Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22594 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/export/pdf/issues_pdf_helper.rb | 4 +++- test/unit/lib/redmine/export/pdf/issues_pdf_test.rb | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb index 85330e9cb..834cd6db8 100644 --- a/lib/redmine/export/pdf/issues_pdf_helper.rb +++ b/lib/redmine/export/pdf/issues_pdf_helper.rb @@ -21,6 +21,8 @@ module Redmine module Export module PDF module IssuesPdfHelper + include ActionView::Helpers::NumberHelper + # Returns a PDF string of a single issue def issue_to_pdf(issue, assoc={}) pdf = ITCPDF.new(current_language) @@ -406,7 +408,7 @@ module Redmine elsif value.is_a?(Time) format_time(value) elsif value.is_a?(Float) - sprintf "%.2f", value + number_with_delimiter(sprintf('%.2f', value), delimiter: nil) else value end diff --git a/test/unit/lib/redmine/export/pdf/issues_pdf_test.rb b/test/unit/lib/redmine/export/pdf/issues_pdf_test.rb index 4dd40b9fc..e150aca84 100644 --- a/test/unit/lib/redmine/export/pdf/issues_pdf_test.rb +++ b/test/unit/lib/redmine/export/pdf/issues_pdf_test.rb @@ -33,8 +33,13 @@ class IssuesPdfHelperTest < ActiveSupport::TestCase time_entry = TimeEntry.create!(:spent_on => Date.today, :hours => 4.3432, :user => user, :author => user, :project_id => 1, :issue => issue, :activity => TimeEntryActivity.first) - results = fetch_row_values(issue, query, 0) - assert_equal ["2", "Add ingredients categories", "4.34"], results + to_test = {'en' => '4.34', 'de' => '4,34'} + to_test.each do |locale, expected| + with_locale locale do + results = fetch_row_values(issue, query, 0) + assert_equal ['2', 'Add ingredients categories', expected], results + end + end end def test_fetch_row_values_should_be_able_to_handle_parent_issue_subject -- 2.39.5