fix for #8973: Export feature(to csv/pdf) doesn't work in Japanese
csv and pdf encoding are know defined for each language (general_csv_encoding and general_pdf_encoding keys in lang files) added SJIS font for japanese pdf exports git-svn-id: http://redmine.rubyforge.org/svn/trunk@287 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -262,7 +262,7 @@ class ProjectsController < ApplicationController
|
||||
:conditions => @query.statement,
|
||||
:limit => Setting.issues_export_limit
|
||||
|
||||
ic = Iconv.new('ISO-8859-1', 'UTF-8')
|
||||
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
||||
export = StringIO.new
|
||||
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
||||
# csv header fields
|
||||
|
||||
@@ -16,20 +16,37 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require 'iconv'
|
||||
require 'rfpdf/chinese'
|
||||
|
||||
module IfpdfHelper
|
||||
|
||||
module IfpdfHelper
|
||||
|
||||
class IFPDF < FPDF
|
||||
|
||||
include GLoc
|
||||
attr_accessor :footer_date
|
||||
|
||||
def initialize
|
||||
super
|
||||
def initialize(lang)
|
||||
super()
|
||||
set_language_if_valid lang
|
||||
case current_language
|
||||
when :ja
|
||||
extend(PDF_Japanese)
|
||||
AddSJISFont()
|
||||
@font_for_content = 'SJIS'
|
||||
@font_for_footer = 'SJIS'
|
||||
else
|
||||
@font_for_content = 'Arial'
|
||||
@font_for_footer = 'Helvetica'
|
||||
end
|
||||
SetCreator("redMine #{Redmine::VERSION}")
|
||||
SetFont(@font_for_content)
|
||||
end
|
||||
|
||||
def SetFontStyle(style, size)
|
||||
SetFont(@font_for_content, style, size)
|
||||
end
|
||||
|
||||
def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
|
||||
@ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
|
||||
@ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
|
||||
txt = begin
|
||||
@ic.iconv(txt)
|
||||
rescue
|
||||
@@ -39,7 +56,7 @@ module IfpdfHelper
|
||||
end
|
||||
|
||||
def Footer
|
||||
SetFont('Helvetica', 'I', 8)
|
||||
SetFont(@font_for_footer, 'I', 8)
|
||||
SetY(-15)
|
||||
SetX(15)
|
||||
Cell(0, 5, @footer_date, 0, 0, 'L')
|
||||
|
||||
+29
-29
@@ -1,65 +1,65 @@
|
||||
<% pdf.SetFont('Arial','B',11)
|
||||
<% pdf.SetFontStyle('B',11)
|
||||
pdf.Cell(190,10, "#{issue.project.name} - #{issue.tracker.name} # #{issue.long_id} - #{issue.subject}")
|
||||
pdf.Ln
|
||||
|
||||
y0 = pdf.GetY
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_status) + ":","LT")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.status.name,"RT")
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_priority) + ":","LT")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.priority.name,"RT")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_author) + ":","L")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, issue.author.name,"R")
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_category) + ":","L")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, (issue.category ? issue.category.name : "-"),"R")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_created_on) + ":","L")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.created_on),"R")
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_assigned_to) + ":","L")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, (issue.assigned_to ? issue.assigned_to.name : "-"),"R")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_updated_on) + ":","LB")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.updated_on),"RB")
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_due_date) + ":","LB")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(60,5, format_date(issue.due_date),"RB")
|
||||
pdf.Ln
|
||||
|
||||
for custom_value in issue.custom_values
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, custom_value.custom_field.name + ":","L")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.MultiCell(155,5, (show_value custom_value),"R")
|
||||
end
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_subject) + ":","LTB")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.Cell(155,5, issue.subject,"RTB")
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(35,5, l(:field_description) + ":")
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.MultiCell(155,5, issue.description,"BR")
|
||||
|
||||
pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
|
||||
@@ -67,30 +67,30 @@
|
||||
|
||||
pdf.Ln
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(190,5, l(:label_history), "B")
|
||||
pdf.Ln
|
||||
for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")
|
||||
pdf.SetFont('Arial','B',8)
|
||||
pdf.SetFontStyle('B',8)
|
||||
pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
|
||||
pdf.Ln
|
||||
pdf.SetFont('Arial','I',8)
|
||||
pdf.SetFontStyle('I',8)
|
||||
for detail in journal.details
|
||||
pdf.Cell(190,5, "- " + show_detail(detail, true))
|
||||
pdf.Ln
|
||||
end
|
||||
if journal.notes?
|
||||
pdf.SetFont('Arial','',8)
|
||||
pdf.SetFontStyle('',8)
|
||||
pdf.MultiCell(190,5, journal.notes)
|
||||
end
|
||||
pdf.Ln
|
||||
end
|
||||
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
pdf.Cell(190,5, l(:label_attachment_plural), "B")
|
||||
pdf.Ln
|
||||
for attachment in issue.attachments
|
||||
pdf.SetFont('Arial','',8)
|
||||
pdf.SetFontStyle('',8)
|
||||
pdf.Cell(80,5, attachment.filename)
|
||||
pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
|
||||
pdf.Cell(20,5, format_date(attachment.created_on),0,0,"R")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% pdf=IfpdfHelper::IFPDF.new
|
||||
<% pdf=IfpdfHelper::IFPDF.new(current_language)
|
||||
pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")
|
||||
pdf.AliasNbPages
|
||||
pdf.footer_date = format_date(Date.today)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% pdf=IfpdfHelper::IFPDF.new
|
||||
<% pdf=IfpdfHelper::IFPDF.new(current_language)
|
||||
pdf.SetTitle("#{@project.name} - #{l(:label_issue_plural)}")
|
||||
pdf.AliasNbPages
|
||||
pdf.footer_date = format_date(Date.today)
|
||||
@@ -8,14 +8,14 @@
|
||||
#
|
||||
# title
|
||||
#
|
||||
pdf.SetFont('Arial','B',11)
|
||||
pdf.SetFontStyle('B',11)
|
||||
pdf.Cell(190,10, "#{@project.name} - #{l(:label_issue_plural)}")
|
||||
pdf.Ln
|
||||
|
||||
#
|
||||
# headers
|
||||
#
|
||||
pdf.SetFont('Arial','B',10)
|
||||
pdf.SetFontStyle('B',10)
|
||||
pdf.SetFillColor(230, 230, 230)
|
||||
pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)
|
||||
pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)
|
||||
@@ -32,7 +32,7 @@
|
||||
#
|
||||
# rows
|
||||
#
|
||||
pdf.SetFont('Arial','',9)
|
||||
pdf.SetFontStyle('',9)
|
||||
pdf.SetFillColor(255, 255, 255)
|
||||
@issues.each do |issue|
|
||||
pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<%
|
||||
pdf=IfpdfHelper::IFPDF.new
|
||||
pdf=IfpdfHelper::IFPDF.new(current_language)
|
||||
pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")
|
||||
pdf.AliasNbPages
|
||||
pdf.footer_date = format_date(Date.today)
|
||||
pdf.AddPage("L")
|
||||
pdf.SetFont('Arial','B',12)
|
||||
pdf.SetFontStyle('B',12)
|
||||
pdf.SetX(15)
|
||||
pdf.Cell(70, 20, @project.name)
|
||||
pdf.Ln
|
||||
pdf.SetFont('Arial','B',9)
|
||||
pdf.SetFontStyle('B',9)
|
||||
|
||||
subject_width = 70
|
||||
header_heigth = 5
|
||||
@@ -84,7 +84,7 @@ if show_days
|
||||
left = subject_width
|
||||
height = header_heigth
|
||||
wday = @date_from.cwday
|
||||
pdf.SetFont('Arial','B',7)
|
||||
pdf.SetFontStyle('B',7)
|
||||
(@date_to - @date_from + 1).to_i.times do
|
||||
width = zoom
|
||||
pdf.SetY(y_start + 2 * header_heigth)
|
||||
@@ -105,7 +105,7 @@ pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
|
||||
# Tasks
|
||||
#
|
||||
top = headers_heigth + y_start
|
||||
pdf.SetFont('Arial','B',7)
|
||||
pdf.SetFontStyle('B',7)
|
||||
@issues.each do |i|
|
||||
pdf.SetY(top)
|
||||
pdf.SetX(15)
|
||||
|
||||
Reference in New Issue
Block a user