##// END OF EJS Templates
fix for #8973: Export feature(to csv/pdf) doesn't work in Japanese...
Jean-Philippe Lang -
r284:6a875eb69184
parent child
Show More
@@ -262,7 +262,7 class ProjectsController < ApplicationController
262 262 :conditions => @query.statement,
263 263 :limit => Setting.issues_export_limit
264 264
265 ic = Iconv.new('ISO-8859-1', 'UTF-8')
265 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
266 266 export = StringIO.new
267 267 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
268 268 # csv header fields
@@ -16,20 +16,37
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'iconv'
19 require 'rfpdf/chinese'
19 20
20 21 module IfpdfHelper
21 22
22 23 class IFPDF < FPDF
23
24 include GLoc
24 25 attr_accessor :footer_date
25 26
26 def initialize
27 super
27 def initialize(lang)
28 super()
29 set_language_if_valid lang
30 case current_language
31 when :ja
32 extend(PDF_Japanese)
33 AddSJISFont()
34 @font_for_content = 'SJIS'
35 @font_for_footer = 'SJIS'
36 else
37 @font_for_content = 'Arial'
38 @font_for_footer = 'Helvetica'
39 end
28 40 SetCreator("redMine #{Redmine::VERSION}")
41 SetFont(@font_for_content)
42 end
43
44 def SetFontStyle(style, size)
45 SetFont(@font_for_content, style, size)
29 46 end
30 47
31 48 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
32 @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
49 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
33 50 txt = begin
34 51 @ic.iconv(txt)
35 52 rescue
@@ -39,7 +56,7 module IfpdfHelper
39 56 end
40 57
41 58 def Footer
42 SetFont('Helvetica', 'I', 8)
59 SetFont(@font_for_footer, 'I', 8)
43 60 SetY(-15)
44 61 SetX(15)
45 62 Cell(0, 5, @footer_date, 0, 0, 'L')
@@ -1,65 +1,65
1 <% pdf.SetFont('Arial','B',11)
1 <% pdf.SetFontStyle('B',11)
2 2 pdf.Cell(190,10, "#{issue.project.name} - #{issue.tracker.name} # #{issue.long_id} - #{issue.subject}")
3 3 pdf.Ln
4 4
5 5 y0 = pdf.GetY
6 6
7 pdf.SetFont('Arial','B',9)
7 pdf.SetFontStyle('B',9)
8 8 pdf.Cell(35,5, l(:field_status) + ":","LT")
9 pdf.SetFont('Arial','',9)
9 pdf.SetFontStyle('',9)
10 10 pdf.Cell(60,5, issue.status.name,"RT")
11 pdf.SetFont('Arial','B',9)
11 pdf.SetFontStyle('B',9)
12 12 pdf.Cell(35,5, l(:field_priority) + ":","LT")
13 pdf.SetFont('Arial','',9)
13 pdf.SetFontStyle('',9)
14 14 pdf.Cell(60,5, issue.priority.name,"RT")
15 15 pdf.Ln
16 16
17 pdf.SetFont('Arial','B',9)
17 pdf.SetFontStyle('B',9)
18 18 pdf.Cell(35,5, l(:field_author) + ":","L")
19 pdf.SetFont('Arial','',9)
19 pdf.SetFontStyle('',9)
20 20 pdf.Cell(60,5, issue.author.name,"R")
21 pdf.SetFont('Arial','B',9)
21 pdf.SetFontStyle('B',9)
22 22 pdf.Cell(35,5, l(:field_category) + ":","L")
23 pdf.SetFont('Arial','',9)
23 pdf.SetFontStyle('',9)
24 24 pdf.Cell(60,5, (issue.category ? issue.category.name : "-"),"R")
25 25 pdf.Ln
26 26
27 pdf.SetFont('Arial','B',9)
27 pdf.SetFontStyle('B',9)
28 28 pdf.Cell(35,5, l(:field_created_on) + ":","L")
29 pdf.SetFont('Arial','',9)
29 pdf.SetFontStyle('',9)
30 30 pdf.Cell(60,5, format_date(issue.created_on),"R")
31 pdf.SetFont('Arial','B',9)
31 pdf.SetFontStyle('B',9)
32 32 pdf.Cell(35,5, l(:field_assigned_to) + ":","L")
33 pdf.SetFont('Arial','',9)
33 pdf.SetFontStyle('',9)
34 34 pdf.Cell(60,5, (issue.assigned_to ? issue.assigned_to.name : "-"),"R")
35 35 pdf.Ln
36 36
37 pdf.SetFont('Arial','B',9)
37 pdf.SetFontStyle('B',9)
38 38 pdf.Cell(35,5, l(:field_updated_on) + ":","LB")
39 pdf.SetFont('Arial','',9)
39 pdf.SetFontStyle('',9)
40 40 pdf.Cell(60,5, format_date(issue.updated_on),"RB")
41 pdf.SetFont('Arial','B',9)
41 pdf.SetFontStyle('B',9)
42 42 pdf.Cell(35,5, l(:field_due_date) + ":","LB")
43 pdf.SetFont('Arial','',9)
43 pdf.SetFontStyle('',9)
44 44 pdf.Cell(60,5, format_date(issue.due_date),"RB")
45 45 pdf.Ln
46 46
47 47 for custom_value in issue.custom_values
48 pdf.SetFont('Arial','B',9)
48 pdf.SetFontStyle('B',9)
49 49 pdf.Cell(35,5, custom_value.custom_field.name + ":","L")
50 pdf.SetFont('Arial','',9)
50 pdf.SetFontStyle('',9)
51 51 pdf.MultiCell(155,5, (show_value custom_value),"R")
52 52 end
53 53
54 pdf.SetFont('Arial','B',9)
54 pdf.SetFontStyle('B',9)
55 55 pdf.Cell(35,5, l(:field_subject) + ":","LTB")
56 pdf.SetFont('Arial','',9)
56 pdf.SetFontStyle('',9)
57 57 pdf.Cell(155,5, issue.subject,"RTB")
58 58 pdf.Ln
59 59
60 pdf.SetFont('Arial','B',9)
60 pdf.SetFontStyle('B',9)
61 61 pdf.Cell(35,5, l(:field_description) + ":")
62 pdf.SetFont('Arial','',9)
62 pdf.SetFontStyle('',9)
63 63 pdf.MultiCell(155,5, issue.description,"BR")
64 64
65 65 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
@@ -67,30 +67,30
67 67
68 68 pdf.Ln
69 69
70 pdf.SetFont('Arial','B',9)
70 pdf.SetFontStyle('B',9)
71 71 pdf.Cell(190,5, l(:label_history), "B")
72 72 pdf.Ln
73 73 for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")
74 pdf.SetFont('Arial','B',8)
74 pdf.SetFontStyle('B',8)
75 75 pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
76 76 pdf.Ln
77 pdf.SetFont('Arial','I',8)
77 pdf.SetFontStyle('I',8)
78 78 for detail in journal.details
79 79 pdf.Cell(190,5, "- " + show_detail(detail, true))
80 80 pdf.Ln
81 81 end
82 82 if journal.notes?
83 pdf.SetFont('Arial','',8)
83 pdf.SetFontStyle('',8)
84 84 pdf.MultiCell(190,5, journal.notes)
85 85 end
86 86 pdf.Ln
87 87 end
88 88
89 pdf.SetFont('Arial','B',9)
89 pdf.SetFontStyle('B',9)
90 90 pdf.Cell(190,5, l(:label_attachment_plural), "B")
91 91 pdf.Ln
92 92 for attachment in issue.attachments
93 pdf.SetFont('Arial','',8)
93 pdf.SetFontStyle('',8)
94 94 pdf.Cell(80,5, attachment.filename)
95 95 pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
96 96 pdf.Cell(20,5, format_date(attachment.created_on),0,0,"R")
@@ -1,4 +1,4
1 <% pdf=IfpdfHelper::IFPDF.new
1 <% pdf=IfpdfHelper::IFPDF.new(current_language)
2 2 pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")
3 3 pdf.AliasNbPages
4 4 pdf.footer_date = format_date(Date.today)
@@ -1,4 +1,4
1 <% pdf=IfpdfHelper::IFPDF.new
1 <% pdf=IfpdfHelper::IFPDF.new(current_language)
2 2 pdf.SetTitle("#{@project.name} - #{l(:label_issue_plural)}")
3 3 pdf.AliasNbPages
4 4 pdf.footer_date = format_date(Date.today)
@@ -8,14 +8,14
8 8 #
9 9 # title
10 10 #
11 pdf.SetFont('Arial','B',11)
11 pdf.SetFontStyle('B',11)
12 12 pdf.Cell(190,10, "#{@project.name} - #{l(:label_issue_plural)}")
13 13 pdf.Ln
14 14
15 15 #
16 16 # headers
17 17 #
18 pdf.SetFont('Arial','B',10)
18 pdf.SetFontStyle('B',10)
19 19 pdf.SetFillColor(230, 230, 230)
20 20 pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)
21 21 pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)
@@ -32,7 +32,7
32 32 #
33 33 # rows
34 34 #
35 pdf.SetFont('Arial','',9)
35 pdf.SetFontStyle('',9)
36 36 pdf.SetFillColor(255, 255, 255)
37 37 @issues.each do |issue|
38 38 pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)
@@ -1,14 +1,14
1 1 <%
2 pdf=IfpdfHelper::IFPDF.new
2 pdf=IfpdfHelper::IFPDF.new(current_language)
3 3 pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")
4 4 pdf.AliasNbPages
5 5 pdf.footer_date = format_date(Date.today)
6 6 pdf.AddPage("L")
7 pdf.SetFont('Arial','B',12)
7 pdf.SetFontStyle('B',12)
8 8 pdf.SetX(15)
9 9 pdf.Cell(70, 20, @project.name)
10 10 pdf.Ln
11 pdf.SetFont('Arial','B',9)
11 pdf.SetFontStyle('B',9)
12 12
13 13 subject_width = 70
14 14 header_heigth = 5
@@ -84,7 +84,7 if show_days
84 84 left = subject_width
85 85 height = header_heigth
86 86 wday = @date_from.cwday
87 pdf.SetFont('Arial','B',7)
87 pdf.SetFontStyle('B',7)
88 88 (@date_to - @date_from + 1).to_i.times do
89 89 width = zoom
90 90 pdf.SetY(y_start + 2 * header_heigth)
@@ -105,7 +105,7 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
105 105 # Tasks
106 106 #
107 107 top = headers_heigth + y_start
108 pdf.SetFont('Arial','B',7)
108 pdf.SetFontStyle('B',7)
109 109 @issues.each do |i|
110 110 pdf.SetY(top)
111 111 pdf.SetX(15)
@@ -46,6 +46,8 general_text_no: 'nein'
46 46 general_text_yes: 'ja'
47 47 general_lang_de: 'Deutsch'
48 48 general_csv_separator: ';'
49 general_csv_encoding: ISO-8859-1
50 general_pdf_encoding: ISO-8859-1
49 51 general_day_names: Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag
50 52
51 53 notice_account_updated: Konto wurde erfolgreich aktualisiert.
@@ -46,6 +46,8 general_text_no: 'no'
46 46 general_text_yes: 'yes'
47 47 general_lang_en: 'English'
48 48 general_csv_separator: ','
49 general_csv_encoding: ISO-8859-1
50 general_pdf_encoding: ISO-8859-1
49 51 general_day_names: Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday
50 52
51 53 notice_account_updated: Account was successfully updated.
@@ -46,6 +46,8 general_text_no: 'no'
46 46 general_text_yes: 'sí'
47 47 general_lang_es: 'Español'
48 48 general_csv_separator: ';'
49 general_csv_encoding: ISO-8859-1
50 general_pdf_encoding: ISO-8859-1
49 51 general_day_names: Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo
50 52
51 53 notice_account_updated: Account was successfully updated.
@@ -46,6 +46,8 general_text_no: 'non'
46 46 general_text_yes: 'oui'
47 47 general_lang_fr: 'Français'
48 48 general_csv_separator: ';'
49 general_csv_encoding: ISO-8859-1
50 general_pdf_encoding: ISO-8859-1
49 51 general_day_names: Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi,Dimanche
50 52
51 53 notice_account_updated: Le compte a été mis à jour avec succès.
@@ -38,7 +38,7 activerecord_error_greater_than_start_date: を開始日より後にしてくだ
38 38 general_fmt_age: %d歳
39 39 general_fmt_age_plural: %d歳
40 40 general_fmt_date: %%Y年%%m月%%d日
41 general_fmt_datetime: %%Y年%%月%%d日 %%H:%%M %%p
41 general_fmt_datetime: %%Y年%%m月%%d日 %%H:%%M %%p
42 42 general_fmt_datetime_short: %%b %%d, %%H:%%M %%p
43 43 general_fmt_time: %%H:%%M %%p
44 44 general_text_No: 'いいえ'
@@ -47,6 +47,8 general_text_no: 'いいえ'
47 47 general_text_yes: 'はい'
48 48 general_lang_ja: 'Japanese (日本語)'
49 49 general_csv_separator: ','
50 general_csv_encoding: SJIS
51 general_pdf_encoding: SJIS
50 52 general_day_names: 日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日
51 53
52 54 notice_account_updated: アカウントが更新されました。
@@ -78,7 +80,7 field_summary: サマリ
78 80 field_is_required: 必須
79 81 field_firstname: 名前
80 82 field_lastname: 苗字
81 field_mail: Email
83 field_mail: メールアドレス
82 84 field_filename: ファイル
83 85 field_filesize: サイズ
84 86 field_downloads: ダウンロード
@@ -116,15 +118,15 field_is_in_chlog: 変更記録に表示されている問題
116 118 field_login: ログイン
117 119 field_mail_notification: メール通知
118 120 field_admin: 管理者
119 field_locked: Locked
121 field_locked: ロック済
120 122 field_last_login_on: 最終接続日
121 123 field_language: 言語
122 field_effective_date: Date
124 field_effective_date: 日付
123 125 field_password: パスワード
124 126 field_new_password: 新しいパスワード
125 127 field_password_confirmation: パスワードの確認
126 128 field_version: バージョン
127 field_type: Type
129 field_type: タイプ
128 130 field_host: ホスト
129 131 field_port: ポート
130 132 field_account: アカウント
@@ -133,7 +135,7 field_attr_login: ログイン名属性
133 135 field_attr_firstname: 名前属性
134 136 field_attr_lastname: 苗字属性
135 137 field_attr_mail: メール属性
136 field_onthefly: On-the-fly user creation
138 field_onthefly: あわせてユーザを作成
137 139 field_start_date: 開始日
138 140 field_done_ratio: 進捗 %%
139 141 field_auth_source: 認証モード
@@ -316,9 +318,9 label_sort_higher: 上へ
316 318 label_sort_lower: 下へ
317 319 label_sort_lowest: 一番下へ
318 320 label_roadmap: ロードマップ
319 label_search: Search
320 label_result: %d result
321 label_result_plural: %d results
321 label_search: 検索
322 label_result: %d 件の結果
323 label_result_plural: %d 件の結果
322 324
323 325 button_login: ログイン
324 326 button_submit: 変更
@@ -344,11 +346,11 button_cancel: キャンセル
344 346 button_activate: 有効にする
345 347 button_sort: ソート
346 348
347 text_select_mail_notifications: どのメール通知を送信するかアクションを選択してください。
349 text_select_mail_notifications: どのメール通知を送信するかアクションを選択してください。
348 350 text_regexp_info: 例) ^[A-Z0-9]+$
349 351 text_min_max_length_info: 0だと無制限になります
350 352 text_project_destroy_confirmation: 本当にこのプロジェクトと関連データを削除したいのですか?
351 text_workflow_edit: ワークフローを編集するロールとtrackerを選んでください
353 text_workflow_edit: ワークフローを編集するロールとトラッカーを選んでください
352 354 text_are_you_sure: 本当に?
353 355 text_journal_changed: %s から %s への変更
354 356 text_journal_set_to: %s にセット
@@ -146,13 +146,13 module PDF_Japanese
146 146 b2='LR'
147 147 else
148 148 b2=''
149 if(border.index('L').nil?)
149 if(border.to_s.index('L'))
150 150 b2+='L'
151 151 end
152 if(border.index('R').nil?)
152 if(border.to_s.index('R'))
153 153 b2+='R'
154 154 end
155 b=border.index('T').nil? ? b2+'T' : b2
155 b=border.to_s.index('T') ? b2+'T' : b2
156 156 end
157 157 end
158 158 sep=-1
@@ -163,7 +163,7 module PDF_Japanese
163 163 while(i<nb)
164 164 #Get next character
165 165 c=s[i]
166 o=ord(c)
166 o=c #o=ord(c)
167 167 if(o==10)
168 168 #Explicit line break
169 169 Cell(w,h,s[j,i-j],b,2,align,fill)
@@ -221,7 +221,7 module PDF_Japanese
221 221 end
222 222 end
223 223 #Last chunk
224 if(border and not border.index('B').nil?)
224 if(border and not border.to_s.index('B').nil?)
225 225 b+='B'
226 226 end
227 227 Cell(w,h,s[j,i-j],b,2,align,fill)
General Comments 0
You need to be logged in to leave comments. Login now