2011/08/03

レポートの翻訳 (Multiple Language Support with XLIFF)

BI Publisher は多言語のサポートはもちろん、レポートの翻訳機能も備えています。
従来のプログラミングでは、言語の切り替えを実装するためにリソースファイル(言語定義ファイル)を定義し、実行時に切り替える機能を実装する必要がありましたが、BI Publisher では、BI Publisher が自動で生成する定義ファイルに置き換える(翻訳する)単語を記載するだけで同等の要
件を満たすことができます。

大まかな流れは以下のブログに動画で説明されています。


実際のプロジェクトではほぼ確実に、各顧客や従業員または部門にファイルを一斉配信する際、つまりバースティングにおいて動的にレポートロケールを指定したいという要件が上がると考えられます。ここではこの要件に対応する方法を検証します。

【事前準備:データ】
今回は部門毎にレポートロケールが異なるという定義とします。具体的には、以下のようにscott.dept 表に列を追加し、ロケールを指定する文字列を設定します。
部門番号30が日本語、30がアラビア語の設定です。
alter table dept add (locCode varchar2(100));
update dept set locCode = 'en_US' where deptno = 10;
update dept set locCode = 'ja_JP' where deptno = 20;
update dept set locCode = 'ar_EG' where deptno = 30;
update dept set locCode = 'en_US' where deptno = 40;


【事前準備:XLIFF】
翻訳の定義ファイルを編集します。XLIFF(eXtensible Localization Interchange File Format)と呼ばれるXML形式です。
日本語とアラビア語のXLIFFファイルをアップロードします。アップロード後、以下の様に追加の翻訳用ロケールが表示されます。
Figure 1: Translation locale setting


【事前準備:バースティング定義】
バースティング定義では、分割及び配信キーにempnoを指定します。SQL問い合わせの設定は以下の通りです。
select
       empno              as key,
       'Layout1'          as template,
       dept.loccode       as locale,
       'RTF'              as template_format,
       'PDF'              as output_format,
       'FILE'             as del_channel,
       'false'            as save_output,
       'c:\workspace\'    as parameter1,
       to_char(emp.empno,'fm00000') || '_report.pdf'
                          as parameter2
  from emp, dept
 where dept.deptno = emp.deptno
 order by emp.empno

上記のSQLでは、ロケールをdept.loccodeから取得することで、各empnoに応じたロケールを設定します。出力の結果は以下の通りです。部門に応じた翻訳がなされていることが確認できます。

Figure 2: Report in English (deptno = 10, en_US)

Figure 3: Report in Japanese (deptno = 20, ja_JP)

Figure 4: Report in Arabic (deptno = 30, ar_EG)


なお、マニュアルは以下のURLを参照してください。
http://download.oracle.com/docs/cd/E24001_01/bi.1111/b63038/T527073T559221.htm

レポート、データモデルおよび結果のPDFファイルはこちらからダウンロードできます。

[Summary]
BI Publisher supports multiple language.  Also, you can easily translate your report with editing XLIFF (eXtensible Localization Interchange File Format) file.

The following blog post explains overall process.  Please see the movie.


In most of the cases, you would be asked to set appropriate report locale for each recipient.
This post explains how to burst report with changing the report locale dynamically.

[Data]
Add a column on scott.dept that stores the report locale.  In the sample below, dept# 10 is set to English, dept# 20 is Japanese, and dept# 30 is Arabic.

alter table dept add (locCode varchar2(100));
update dept set locCode = 'en_US' where deptno = 10;
update dept set locCode = 'ja_JP' where deptno = 20;
update dept set locCode = 'ar_EG' where deptno = 30;


[XLIFF]
Define the translation file.  create XLIFF files and upload.  See Figure 1.


[Bursting settings]
Set empno for Deliver by and Split by.  The SQL definition is as follows.  This SQL gets the report locale for each empno from dept table (dept.loccode).
select
       empno              as key,
       'Layout1'          as template,
       dept.loccode       as locale,
       'RTF'              as template_format,
       'PDF'              as output_format,
       'FILE'             as del_channel,
       'false'            as save_output,
       'c:\workspace\'    as parameter1,
       to_char(emp.empno,'fm00000') || '_report.pdf'
                          as parameter2
  from emp, dept
 where dept.deptno = emp.deptno
 order by emp.empno

The report (result) is shown in Figure 2 (in English), 3 (in Japanese) and 4 (in Arabic).


For more details, please refer to the manual below.

The report definition, data model and PDF results are available here.

0 件のコメント:

コメントを投稿