]> source.dussan.org Git - redmine.git/commitdiff
fix for #8973: Export feature(to csv/pdf) doesn't work in Japanese
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 1 Mar 2007 19:49:04 +0000 (19:49 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 1 Mar 2007 19:49:04 +0000 (19:49 +0000)
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

12 files changed:
app/controllers/projects_controller.rb
app/helpers/ifpdf_helper.rb
app/views/issues/_pdf.rfpdf
app/views/issues/export_pdf.rfpdf
app/views/projects/export_issues_pdf.rfpdf
app/views/projects/gantt.rfpdf
lang/de.yml
lang/en.yml
lang/es.yml
lang/fr.yml
lang/ja.yml
vendor/plugins/rfpdf/lib/rfpdf/japanese.rb

index a8d943426f876b29e986704a97045a11b9707b2d..e2ddd3df5a0dd1fe4bf4591d36f9e3c7c6ef376f 100644 (file)
@@ -262,7 +262,7 @@ class ProjectsController < ApplicationController
                                                :conditions => @query.statement,\r
                                                :limit => Setting.issues_export_limit\r
 \r
-    ic = Iconv.new('ISO-8859-1', 'UTF-8')    \r
+    ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')    \r
     export = StringIO.new\r
     CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|\r
       # csv header fields\r
index 7c1e3107ef5e16ea9b244559612de0ebef1aa724..481c2c318f31597b18b903248782dca8a3b04c62 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
 \r
 require 'iconv'\r
+require 'rfpdf/chinese'\r
 \r
-module IfpdfHelper\r
-\r
+module IfpdfHelper  \r
+  \r
   class IFPDF < FPDF\r
-\r
+    include GLoc\r
     attr_accessor :footer_date\r
     \r
-    def initialize\r
-      super\r
+    def initialize(lang)\r
+      super()\r
+      set_language_if_valid lang\r
+      case current_language\r
+      when :ja\r
+        extend(PDF_Japanese)\r
+        AddSJISFont()\r
+        @font_for_content = 'SJIS'\r
+        @font_for_footer = 'SJIS'\r
+      else\r
+        @font_for_content = 'Arial'\r
+        @font_for_footer = 'Helvetica'              \r
+      end\r
       SetCreator("redMine #{Redmine::VERSION}")\r
+      SetFont(@font_for_content)\r
+    end\r
+    \r
+    def SetFontStyle(style, size)\r
+      SetFont(@font_for_content, style, size)\r
     end\r
       \r
     def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')\r
-      @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')\r
+      @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')\r
       txt = begin\r
         @ic.iconv(txt)\r
       rescue\r
@@ -39,7 +56,7 @@ module IfpdfHelper
     end\r
     \r
     def Footer\r
-      SetFont('Helvetica', 'I', 8)\r
+      SetFont(@font_for_footer, 'I', 8)\r
       SetY(-15)\r
       SetX(15)\r
       Cell(0, 5, @footer_date, 0, 0, 'L')\r
index 8f09ab72b5b0e24cc7abcbc523e888890e30dbe1..042c6bb0e11278072903d2ed19a7a27d3adb4206 100644 (file)
@@ -1,65 +1,65 @@
-<%     pdf.SetFont('Arial','B',11)     \r
+<%     pdf.SetFontStyle('B',11)        \r
        pdf.Cell(190,10, "#{issue.project.name} - #{issue.tracker.name} # #{issue.long_id} - #{issue.subject}")\r
     pdf.Ln\r
     \r
     y0 = pdf.GetY\r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_status) + ":","LT")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, issue.status.name,"RT")\r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_priority) + ":","LT")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, issue.priority.name,"RT")        \r
     pdf.Ln\r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_author) + ":","L")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, issue.author.name,"R")\r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_category) + ":","L")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, (issue.category ? issue.category.name : "-"),"R")\r
     pdf.Ln   \r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_created_on) + ":","L")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, format_date(issue.created_on),"R")\r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_assigned_to) + ":","L")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, (issue.assigned_to ? issue.assigned_to.name : "-"),"R")\r
     pdf.Ln\r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_updated_on) + ":","LB")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, format_date(issue.updated_on),"RB")\r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_due_date) + ":","LB")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(60,5, format_date(issue.due_date),"RB")\r
     pdf.Ln\r
     \r
        for custom_value in issue.custom_values\r
-           pdf.SetFont('Arial','B',9)\r
+           pdf.SetFontStyle('B',9)\r
            pdf.Cell(35,5, custom_value.custom_field.name + ":","L")\r
-           pdf.SetFont('Arial','',9)\r
+           pdf.SetFontStyle('',9)\r
            pdf.MultiCell(155,5, (show_value custom_value),"R")\r
        end\r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_subject) + ":","LTB")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.Cell(155,5, issue.subject,"RTB")\r
     pdf.Ln    \r
     \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(35,5, l(:field_description) + ":")\r
-    pdf.SetFont('Arial','',9)\r
+    pdf.SetFontStyle('',9)\r
     pdf.MultiCell(155,5, issue.description,"BR")\r
     \r
     pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)\r
 \r
     pdf.Ln\r
 \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(190,5, l(:label_history), "B")\r
     pdf.Ln     \r
        for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")\r
-               pdf.SetFont('Arial','B',8)\r
+               pdf.SetFontStyle('B',8)\r
            pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)\r
            pdf.Ln\r
-               pdf.SetFont('Arial','I',8)\r
+               pdf.SetFontStyle('I',8)\r
                for detail in journal.details\r
                        pdf.Cell(190,5, "- " + show_detail(detail, true))\r
                        pdf.Ln\r
                end\r
                if journal.notes?\r
-                       pdf.SetFont('Arial','',8)\r
+                       pdf.SetFontStyle('',8)\r
                        pdf.MultiCell(190,5, journal.notes)\r
                end             \r
                pdf.Ln\r
        end\r
        \r
-    pdf.SetFont('Arial','B',9)\r
+    pdf.SetFontStyle('B',9)\r
     pdf.Cell(190,5, l(:label_attachment_plural), "B")\r
        pdf.Ln\r
        for attachment in issue.attachments\r
-               pdf.SetFont('Arial','',8)\r
+               pdf.SetFontStyle('',8)\r
            pdf.Cell(80,5, attachment.filename)\r
                pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")\r
                pdf.Cell(20,5, format_date(attachment.created_on),0,0,"R")\r
index e10c116429ee7cdfb94e9f32c43174208ea544a2..51a71c0c1e368873f7ed946c391457afc3b643df 100644 (file)
@@ -1,4 +1,4 @@
-<%     pdf=IfpdfHelper::IFPDF.new\r
+<%     pdf=IfpdfHelper::IFPDF.new(current_language)\r
        pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")\r
        pdf.AliasNbPages\r
        pdf.footer_date = format_date(Date.today)\r
index 4339441aed639d93fbcf5cc295d81ed79f3598cd..dd63d3657958d561c79026055c5efd28ba274c64 100644 (file)
@@ -1,4 +1,4 @@
-<%     pdf=IfpdfHelper::IFPDF.new\r
+<%     pdf=IfpdfHelper::IFPDF.new(current_language)\r
        pdf.SetTitle("#{@project.name} - #{l(:label_issue_plural)}")\r
        pdf.AliasNbPages\r
        pdf.footer_date = format_date(Date.today)\r
@@ -8,14 +8,14 @@
        #\r
        # title\r
        #\r
-       pdf.SetFont('Arial','B',11)     \r
+       pdf.SetFontStyle('B',11)        \r
        pdf.Cell(190,10, "#{@project.name} - #{l(:label_issue_plural)}")\r
     pdf.Ln\r
        \r
        #\r
        # headers\r
        #       \r
-       pdf.SetFont('Arial','B',10)\r
+       pdf.SetFontStyle('B',10)\r
        pdf.SetFillColor(230, 230, 230)\r
        pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)\r
        pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)\r
@@ -32,7 +32,7 @@
        #\r
        # rows\r
        #\r
-       pdf.SetFont('Arial','',9)\r
+       pdf.SetFontStyle('',9)\r
        pdf.SetFillColor(255, 255, 255)\r
        @issues.each do |issue|         \r
                pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)\r
index 780b2d90025c4519be5f5dc76a55676bbdd07c66..6f85ce742b5f8ac24e1b03cd1aed9295d63d04ee 100644 (file)
@@ -1,14 +1,14 @@
 <%\r
-pdf=IfpdfHelper::IFPDF.new\r
+pdf=IfpdfHelper::IFPDF.new(current_language)\r
 pdf.SetTitle("#{@project.name} - #{l(:label_gantt)}")\r
 pdf.AliasNbPages\r
 pdf.footer_date = format_date(Date.today)\r
 pdf.AddPage("L")\r
-pdf.SetFont('Arial','B',12)\r
+pdf.SetFontStyle('B',12)\r
 pdf.SetX(15)\r
 pdf.Cell(70, 20, @project.name)\r
 pdf.Ln\r
-pdf.SetFont('Arial','B',9)\r
+pdf.SetFontStyle('B',9)\r
 \r
 subject_width = 70\r
 header_heigth = 5\r
@@ -84,7 +84,7 @@ if show_days
        left = subject_width\r
        height = header_heigth\r
        wday = @date_from.cwday\r
-       pdf.SetFont('Arial','B',7)\r
+       pdf.SetFontStyle('B',7)\r
        (@date_to - @date_from + 1).to_i.times do \r
                width = zoom\r
                pdf.SetY(y_start + 2 * header_heigth)\r
@@ -105,7 +105,7 @@ pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
 # Tasks\r
 #\r
 top = headers_heigth + y_start\r
-pdf.SetFont('Arial','B',7)\r
+pdf.SetFontStyle('B',7)\r
 @issues.each do |i|\r
        pdf.SetY(top)\r
        pdf.SetX(15)\r
index 4339cad97359f6e66dab00864ca6da3df440f211..7abb5a10583ba51a5c1efe8d6ca34483afd949d6 100644 (file)
@@ -46,6 +46,8 @@ general_text_no: 'nein'
 general_text_yes: 'ja'\r
 general_lang_de: 'Deutsch'\r
 general_csv_separator: ';'\r
+general_csv_encoding: ISO-8859-1\r
+general_pdf_encoding: ISO-8859-1\r
 general_day_names: Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag,Sonntag\r
 \r
 notice_account_updated: Konto wurde erfolgreich aktualisiert.\r
index 27e3cb77f98e88ab96703132ff20469d6352db22..c82f9bbf9ade5824bdfa4c5f5b718c4e6affb15e 100644 (file)
@@ -46,6 +46,8 @@ general_text_no: 'no'
 general_text_yes: 'yes'\r
 general_lang_en: 'English'\r
 general_csv_separator: ','\r
+general_csv_encoding: ISO-8859-1\r
+general_pdf_encoding: ISO-8859-1\r
 general_day_names: Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday\r
 \r
 notice_account_updated: Account was successfully updated.\r
index d09f58bbbe390f51474fe5549e333de8b4376fa6..3d6896f0da7e7aeb862c71c571c1578fe070298c 100644 (file)
@@ -46,6 +46,8 @@ general_text_no: 'no'
 general_text_yes: 'sí'\r
 general_lang_es: 'Español'\r
 general_csv_separator: ';'\r
+general_csv_encoding: ISO-8859-1\r
+general_pdf_encoding: ISO-8859-1\r
 general_day_names: Lunes,Martes,Miércoles,Jueves,Viernes,Sábado,Domingo\r
 \r
 notice_account_updated: Account was successfully updated.\r
index 30a4fb2d90de08e514844afb6edafb3edad00696..f12bac882491cd92a76c1db563877734352fef96 100644 (file)
@@ -46,6 +46,8 @@ general_text_no: 'non'
 general_text_yes: 'oui'\r
 general_lang_fr: 'Français'\r
 general_csv_separator: ';'\r
+general_csv_encoding: ISO-8859-1\r
+general_pdf_encoding: ISO-8859-1\r
 general_day_names: Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi,Dimanche\r
 \r
 notice_account_updated: Le compte a été mis à jour avec succès.\r
index 7336c5781ca498eb5da75520ac275ff8e7fad866..b0423e03f1fed96f1483f28a5d356f78192b8d8a 100644 (file)
@@ -38,7 +38,7 @@ activerecord_error_greater_than_start_date: を開始日より後にしてくだ
 general_fmt_age: %d歳\r
 general_fmt_age_plural: %d歳\r
 general_fmt_date: %%Y年%%m月%%d日\r
-general_fmt_datetime: %%Y年%%月%%d日 %%H:%%M %%p\r
+general_fmt_datetime: %%Y年%%m月%%d日 %%H:%%M %%p\r
 general_fmt_datetime_short: %%b %%d, %%H:%%M %%p\r
 general_fmt_time: %%H:%%M %%p\r
 general_text_No: 'いいえ'\r
@@ -47,6 +47,8 @@ general_text_no: 'いいえ'
 general_text_yes: 'はい'\r
 general_lang_ja: 'Japanese (日本語)'\r
 general_csv_separator: ','\r
+general_csv_encoding: SJIS\r
+general_pdf_encoding: SJIS\r
 general_day_names: 日曜日, 月曜日, 火曜日, 水曜日, 木曜日, 金曜日, 土曜日\r
 \r
 notice_account_updated: アカウントが更新されました。\r
@@ -78,7 +80,7 @@ field_summary: サマリ
 field_is_required: 必須\r
 field_firstname: 名前\r
 field_lastname: 苗字\r
-field_mail: Email\r
+field_mail: メールアドレス\r
 field_filename: ファイル\r
 field_filesize: サイズ\r
 field_downloads: ダウンロード\r
@@ -116,15 +118,15 @@ field_is_in_chlog: 変更記録に表示されている問題
 field_login: ログイン\r
 field_mail_notification: メール通知\r
 field_admin: 管理者\r
-field_locked: Locked\r
+field_locked: ロック済\r
 field_last_login_on: 最終接続日\r
 field_language: 言語\r
-field_effective_date: Date\r
+field_effective_date: 日付\r
 field_password: パスワード\r
 field_new_password: 新しいパスワード\r
 field_password_confirmation: パスワードの確認\r
 field_version: バージョン\r
-field_type: Type\r
+field_type: タイプ\r
 field_host: ホスト\r
 field_port: ポート\r
 field_account: アカウント\r
@@ -133,7 +135,7 @@ field_attr_login: ログイン名属性
 field_attr_firstname: 名前属性\r
 field_attr_lastname: 苗字属性\r
 field_attr_mail: メール属性\r
-field_onthefly: On-the-fly user creation\r
+field_onthefly: あわせてユーザを作成\r
 field_start_date: 開始日\r
 field_done_ratio: 進捗 %%\r
 field_auth_source: 認証モード\r
@@ -300,8 +302,8 @@ label_not_contains: 含まない
 label_day_plural: 日\r
 label_repository: SVNリポジトリ\r
 label_browse: ブラウズ\r
-label_modification: %d点の変更\r
-label_modification_plural: %d点の変更\r
+label_modification: %d 点の変更\r
+label_modification_plural: %d 点の変更\r
 label_revision: リビジョン\r
 label_revision_plural: リビジョン\r
 label_added: 追加された\r
@@ -316,9 +318,9 @@ label_sort_higher: 上へ
 label_sort_lower: 下へ\r
 label_sort_lowest: 一番下へ\r
 label_roadmap: ロードマップ\r
-label_search: Search\r
-label_result: %d result\r
-label_result_plural: %d results\r
+label_search: 検索\r
+label_result: %d 件の結果\r
+label_result_plural: %d 件の結果\r
 \r
 button_login: ログイン\r
 button_submit: 変更\r
@@ -344,11 +346,11 @@ button_cancel: キャンセル
 button_activate: 有効にする\r
 button_sort: ソート\r
 \r
-text_select_mail_notifications: どのメール通知を送信するかアクションを選択してください。\r
+text_select_mail_notifications: ã\81©ã\81®ã\83¡ã\83¼ã\83«é\80\9aç\9f¥ã\82\92é\80\81ä¿¡ã\81\99ã\82\8bã\81\8bã\80\81ã\82¢ã\82¯ã\82·ã\83§ã\83³ã\82\92é\81¸æ\8a\9eã\81\97ã\81¦ã\81\8fã\81 ã\81\95ã\81\84ã\80\82\r
 text_regexp_info: 例) ^[A-Z0-9]+$\r
 text_min_max_length_info: 0だと無制限になります\r
 text_project_destroy_confirmation: 本当にこのプロジェクトと関連データを削除したいのですか?\r
-text_workflow_edit: ワークフローを編集するロールとtrackerを選んでください\r
+text_workflow_edit: ワークフローを編集するロールとトラッカーを選んでください\r
 text_are_you_sure: 本当に?\r
 text_journal_changed: %s から %s への変更\r
 text_journal_set_to: %s にセット\r
index 7340936bbf73eefcc1f579c294c58f953ece769f..4e611a6f696300689cb5a9ba927ef5e36e067cea 100644 (file)
@@ -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)