summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-01 19:49:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-01 19:49:04 +0000
commit6a875eb691844b78786d95d45e3c457bc67fc9a2 (patch)
tree387b24c7d7d1099505ed715f0bd3465413041cff
parent83c96d4f3ef2adb8ec3226f82bc68e8f1accd6d9 (diff)
downloadredmine-6a875eb691844b78786d95d45e3c457bc67fc9a2.tar.gz
redmine-6a875eb691844b78786d95d45e3c457bc67fc9a2.zip
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
-rw-r--r--app/controllers/projects_controller.rb2
-rw-r--r--app/helpers/ifpdf_helper.rb31
-rw-r--r--app/views/issues/_pdf.rfpdf58
-rw-r--r--app/views/issues/export_pdf.rfpdf2
-rw-r--r--app/views/projects/export_issues_pdf.rfpdf8
-rw-r--r--app/views/projects/gantt.rfpdf10
-rw-r--r--lang/de.yml2
-rw-r--r--lang/en.yml2
-rw-r--r--lang/es.yml2
-rw-r--r--lang/fr.yml2
-rw-r--r--lang/ja.yml28
-rw-r--r--vendor/plugins/rfpdf/lib/rfpdf/japanese.rb10
12 files changed, 92 insertions, 65 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index a8d943426..e2ddd3df5 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -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
diff --git a/app/helpers/ifpdf_helper.rb b/app/helpers/ifpdf_helper.rb
index 7c1e3107e..481c2c318 100644
--- a/app/helpers/ifpdf_helper.rb
+++ b/app/helpers/ifpdf_helper.rb
@@ -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')
diff --git a/app/views/issues/_pdf.rfpdf b/app/views/issues/_pdf.rfpdf
index 8f09ab72b..042c6bb0e 100644
--- a/app/views/issues/_pdf.rfpdf
+++ b/app/views/issues/_pdf.rfpdf
@@ -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")
diff --git a/app/views/issues/export_pdf.rfpdf b/app/views/issues/export_pdf.rfpdf
index e10c11642..51a71c0c1 100644
--- a/app/views/issues/export_pdf.rfpdf
+++ b/app/views/issues/export_pdf.rfpdf
@@ -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)
diff --git a/app/views/projects/export_issues_pdf.rfpdf b/app/views/projects/export_issues_pdf.rfpdf
index 4339441ae..dd63d3657 100644
--- a/app/views/projects/export_issues_pdf.rfpdf
+++ b/app/views/projects/export_issues_pdf.rfpdf
@@ -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)
diff --git a/app/views/projects/gantt.rfpdf b/app/views/projects/gantt.rfpdf
index 780b2d900..6f85ce742 100644
--- a/app/views/projects/gantt.rfpdf
+++ b/app/views/projects/gantt.rfpdf
@@ -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)
diff --git a/lang/de.yml b/lang/de.yml
index 4339cad97..7abb5a105 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -46,6 +46,8 @@ general_text_no: 'nein'
general_text_yes: 'ja'
general_lang_de: 'Deutsch'
general_csv_separator: ';'
+general_csv_encoding: ISO-8859-1
+general_pdf_encoding: ISO-8859-1
general_day_names: Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag
notice_account_updated: Konto wurde erfolgreich aktualisiert.
diff --git a/lang/en.yml b/lang/en.yml
index 27e3cb77f..c82f9bbf9 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -46,6 +46,8 @@ general_text_no: 'no'
general_text_yes: 'yes'
general_lang_en: 'English'
general_csv_separator: ','
+general_csv_encoding: ISO-8859-1
+general_pdf_encoding: ISO-8859-1
general_day_names: Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday
notice_account_updated: Account was successfully updated.
diff --git a/lang/es.yml b/lang/es.yml
index d09f58bbb..3d6896f0d 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -46,6 +46,8 @@ general_text_no: 'no'
general_text_yes: 'sí'
general_lang_es: 'Español'
general_csv_separator: ';'
+general_csv_encoding: ISO-8859-1
+general_pdf_encoding: ISO-8859-1
general_day_names: Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo
notice_account_updated: Account was successfully updated.
diff --git a/lang/fr.yml b/lang/fr.yml
index 30a4fb2d9..f12bac882 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -46,6 +46,8 @@ general_text_no: 'non'
general_text_yes: 'oui'
general_lang_fr: 'Français'
general_csv_separator: ';'
+general_csv_encoding: ISO-8859-1
+general_pdf_encoding: ISO-8859-1
general_day_names: Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi,Dimanche
notice_account_updated: Le compte a été mis à jour avec succès.
diff --git a/lang/ja.yml b/lang/ja.yml
index 7336c5781..b0423e03f 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -38,7 +38,7 @@ activerecord_error_greater_than_start_date: を開始日より後にしてくだ
general_fmt_age: %d歳
general_fmt_age_plural: %d歳
general_fmt_date: %%Y年%%m月%%d日
-general_fmt_datetime: %%Y年%%月%%d日 %%H:%%M %%p
+general_fmt_datetime: %%Y年%%m月%%d日 %%H:%%M %%p
general_fmt_datetime_short: %%b %%d, %%H:%%M %%p
general_fmt_time: %%H:%%M %%p
general_text_No: 'いいえ'
@@ -47,6 +47,8 @@ general_text_no: 'いいえ'
general_text_yes: 'はい'
general_lang_ja: 'Japanese (日本語)'
general_csv_separator: ','
+general_csv_encoding: SJIS
+general_pdf_encoding: SJIS
general_day_names: 日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日
notice_account_updated: アカウントが更新されました。
@@ -78,7 +80,7 @@ field_summary: サマリ
field_is_required: 必須
field_firstname: 名前
field_lastname: 苗字
-field_mail: Email
+field_mail: メールアドレス
field_filename: ファイル
field_filesize: サイズ
field_downloads: ダウンロード
@@ -116,15 +118,15 @@ field_is_in_chlog: 変更記録に表示されている問題
field_login: ログイン
field_mail_notification: メール通知
field_admin: 管理者
-field_locked: Locked
+field_locked: ロック済
field_last_login_on: 最終接続日
field_language: 言語
-field_effective_date: Date
+field_effective_date: 日付
field_password: パスワード
field_new_password: 新しいパスワード
field_password_confirmation: パスワードの確認
field_version: バージョン
-field_type: Type
+field_type: タイプ
field_host: ホスト
field_port: ポート
field_account: アカウント
@@ -133,7 +135,7 @@ field_attr_login: ログイン名属性
field_attr_firstname: 名前属性
field_attr_lastname: 苗字属性
field_attr_mail: メール属性
-field_onthefly: On-the-fly user creation
+field_onthefly: あわせてユーザを作成
field_start_date: 開始日
field_done_ratio: 進捗 %%
field_auth_source: 認証モード
@@ -300,8 +302,8 @@ label_not_contains: 含まない
label_day_plural: 日
label_repository: SVNリポジトリ
label_browse: ブラウズ
-label_modification: %d点の変更
-label_modification_plural: %d点の変更
+label_modification: %d 点の変更
+label_modification_plural: %d 点の変更
label_revision: リビジョン
label_revision_plural: リビジョン
label_added: 追加された
@@ -316,9 +318,9 @@ label_sort_higher: 上へ
label_sort_lower: 下へ
label_sort_lowest: 一番下へ
label_roadmap: ロードマップ
-label_search: Search
-label_result: %d result
-label_result_plural: %d results
+label_search: 検索
+label_result: %d 件の結果
+label_result_plural: %d 件の結果
button_login: ログイン
button_submit: 変更
@@ -344,11 +346,11 @@ button_cancel: キャンセル
button_activate: 有効にする
button_sort: ソート
-text_select_mail_notifications: どのメール通知を送信するかアクションを選択してください。
+text_select_mail_notifications: どのメール通知を送信するか、アクションを選択してください。
text_regexp_info: 例) ^[A-Z0-9]+$
text_min_max_length_info: 0だと無制限になります
text_project_destroy_confirmation: 本当にこのプロジェクトと関連データを削除したいのですか?
-text_workflow_edit: ワークフローを編集するロールとtrackerを選んでください
+text_workflow_edit: ワークフローを編集するロールとトラッカーを選んでください
text_are_you_sure: 本当に?
text_journal_changed: %s から %s への変更
text_journal_set_to: %s にセット
diff --git a/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb b/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb
index 7340936bb..4e611a6f6 100644
--- a/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb
+++ b/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb
@@ -146,13 +146,13 @@ module PDF_Japanese
b2='LR'
else
b2=''
- if(border.index('L').nil?)
+ if(border.to_s.index('L'))
b2+='L'
end
- if(border.index('R').nil?)
+ if(border.to_s.index('R'))
b2+='R'
end
- b=border.index('T').nil? ? b2+'T' : b2
+ b=border.to_s.index('T') ? b2+'T' : b2
end
end
sep=-1
@@ -163,7 +163,7 @@ module PDF_Japanese
while(i<nb)
#Get next character
c=s[i]
- o=ord(c)
+ o=c #o=ord(c)
if(o==10)
#Explicit line break
Cell(w,h,s[j,i-j],b,2,align,fill)
@@ -221,7 +221,7 @@ module PDF_Japanese
end
end
#Last chunk
- if(border and not border.index('B').nil?)
+ if(border and not border.to_s.index('B').nil?)
b+='B'
end
Cell(w,h,s[j,i-j],b,2,align,fill)