• 検索結果がありません。

マルチ⾔語プロンプトと⼊⼒コントロールへの静的なリストを追加する

ドキュメント内 JasperReports Server CP User Guide JP (ページ 73-83)

3.6 レポートをローカライズする

3.6.2 マルチ⾔語プロンプトと⼊⼒コントロールへの静的なリストを追加する

サーバは、プロンプトと、ユーザに表⽰する⼊⼒コントロールの値のリストについて、⾔語サポートを提供します。値のリスト を標⽰できる⼊⼒コントロールは以下の通りです。

The server provides linguistic support for the prompt and list of values that an input control can present to users. The input controls that can present a list of values are:

「値の単一選択リスト」

Single-select list of values

「値の単一選択リスト」(ラジオ ボタン)

Single-select list of values (radio)

「値の複数選択リスト」

Multi-select list of values

「値の複数選択リスト(チェックボックス)」 Multi-select list of values (check box)

図 3-31 は、 マルチ言語 Department Report サン プル( イン スト ール時に サンプ ルもイン スト ール して いれば、 Reports/Samples フォルダに入っています)を示しています。プロンプトと値の複数選択リストが、英語またはスペイン語で 標示されています。

Figure 3-31 shows an example of the multi-lingual Department Report in the Reports/Samples folder (if you installed

sample reports during installation). The prompts and the multi-select list of values appear in English or Spanish, depending on the locale you select on the login page.

図 3-31 英語とスペイン語における値の複数選択リスト

このサンプルでは、⼊⼒コントロールのプロンプトと静的な値のリストをマルチ⾔語にローカライズする⽅法について説明しま す。次のタスクを順番に説明します。

This next example shows how to localize an input control to make the prompts and static list of values multi-lingual.

These tasks are explained step-by-step:

リスト⼊⼒コントロールのプロンプトと静的な値のリストをローカライズする。

Edit the list input control to localize prompts and a static list of values.

フランス語に翻訳した新しいリソースバンドルを作成する。

Create a new resource bundle for the French translations.

フランス語リソースバンドルをアップロードする。

Upload the French resource bundle.

英語に翻訳した新しいリソースバンドルを作成する。

Create a new resource bundle for the English translations.

既存の英語リソースバンドルを新しいものに置き換える。

Replace the existing English resource bundle with the new one.

サンプルレポートデザインから不要なパラメータを除去する。

Remove unwanted parameters from the sample report design.

ローカライズされた⼊⼒インプットコントロールを使ってレポートを実⾏する。

Run the report that uses the localized input control.

サンプルレポートを編集して、リスト⼊⼒コントロール定義に$R 表記を追加します。

You edit a sample report to add $R expressions to the list input control definition.

リスト⼊⼒コントロールのプロンプトと静的な値のリストをローカライズするには:

1. サーバに管理者としてログインし、リポジトリにTemp という名前のフォルダを追加します。

Log into the server as administrator and add a folder to the repository named Temp.

2. リポジトリの Reports > Sample フォルダにある「Sales By Month Report」を選択し、[コピー] ボタンをクリックし ます。

Locate the Sales By Month report in the Reports > Samples folder of the repository. Select it and click Copy.

3. Temp フォルダに移動し、[貼り付け] ボタンをクリックします。

すると、「Sales By Month Report」が Temp フォルダ内に標示されます。

Navigate to the Temp folder and choose Paste.

The Sales By Month Report appears in the Temp folder.

4. 「Sales By Month Report」を選択し、[編集] ボタンをクリックします。

すると、JasperReportウィザードが標示されます。

Select the Sales By Month Report and click Edit.

The JasperReport wizard appears.

5. 「コントロールとリソース」をクリックします。

このレポートは 5つの⼊⼒コントロールを持っています。List Input Control と、2 つのリソースバンドルと、その他のリ ソースです。詳細は図 3-25 を参照してください。

Click Controls & Resources.

The report has five input controls, including a List Input Control, two resource bundles, and other resources, as shown in Figure 3-25 on page 51.

6. List Input Control をクリックします。

Click the List Input Control to edit it.

7. 「プロンプトの選択」ページでは、[次へ] ボタンをクリックします。

In Locate Input Control, click Next.

8. 「プロンプトの作成」ページで、「プロンプトのテキスト」を “$R{department_multi}” に変更します。

その様子を図 3-32 に示します。

On the Create Input Control page, change the prompt text from List Input Control to $R{department_multi}.

Figure 3-32 shows the $Rexpression in the Prompt Text field.

図 3-32 プロンプトのテキストフィールドに記された $R 表記 9. [次へ] ボタンをクリックします。

Click Next.

10. 「値リストの選択」ページでは、[次へ] ボタンをクリックします。

すると、「値リストの編集」ページが標示されます。

On the Locate List of Values page, click Next.

The Edit List of Values page appears.

11. 既存の「名前 – 値」ペアをすべて [削除] します。

On the Edit List of Values page, click Remove to remove each existing name-value pair.

12. 以下の「名前 – 値」ペアを [追加] します。

Add these name-value pairs:

名前 値

$R{department_1} 1

$R{department_2} 2

$R{department_3} 3 変更後の様⼦を図 3-33 に示します。

Figure 3-33 shows the edited list ofvalues containing the $R expressions in the name fields.

図 3-33 $R 表記を含んだ値リスト 13. [送信] ボタンをクリックします。

「コントロールとリソース」ページには、新しい⼊⼒コントロールプロンプトが表⽰されています。

「$R{department_multi}」は、⼊⼒コントロールのリストによって、List Input Control に置き換えられます。

Click Submit.

The Controls & Resources page shows the change to the input control prompt. The expression

$R{department_multi} replaces List Input Control in the list of input controls.

14. 再び [送信] ボタンをクリックし、この変更を保存します。

Click Submit again to save your work.

フランス語に翻訳した新しいリソースバンドルを作成するには:

1. テキストエディタで新しいフランス語翻訳⽤のファイルを作成し、⼊⼒コントロール⽤に以下の「名前 – 値」ペアを⼊⼒

します。

In a text editor, create a new file for French translations, and enter these name-value pairs for the input control department_multi=Choisir le service

department_1 = Travail # 1 department_2 = Travail # 2 department_3 = Travail # 3

2. ファイルの末尾に、ローカライズレポート⽤のフィールドとプロパティの翻訳を⼊⼒します。

At the bottom of the file, enter these field and property translations to localize the report:

title=Rapport de ventes mensuelles sales.person=Commercial

sales.account=Compte sales.amount=Montant param.list=Liste Détaillée

もし「é」が⼊⼒できない場合は、Unicode エスケープ「\u00e9」を使ってください。

Use the Unicode escape sequence if you can’t enter é: \u00e9 3. そのファイルを、「sales_fr.properties」という名前でハードディスクに保存します。

Save the file as sales_fr.properties to your hard drive.

フランス語リソースバンドルをアップロードするには:

1. あなたがまだサーバにログインしているものと仮定して、「Sales By Month Report」を選択し、[編集] ボタンをクリッ クします。

Assuming you’re still logged into the server, select the Sales By Month report, and click Edit.

2. 「コントロールとリソース」ページに移動し、[リソースの追加...] をクリックします。

On the Controls & Resources page, click Add Resource.

3. [ローカル ファイルをアップロード] を選択し、[参照] ボタンをクリックします。

ハードディスクに保存した「sales_fr.properties」を探して選択し、[開く] ボタンをクリックします。

Select Upload a Local File, click Browse, and locate the sales_fr.properties file on your hard drive. Select the file, and click Open.

4. [次へ] ボタンをクリックします。

「レポート リソースの追加」ページで、「選択されたリソース」欄に「sales_fr.properties」が表示されます。これは、

サーバがそのファイルは自動的にリソースバンドルとして検出できたことを示しています。

In Locate File Resource, click Next.

On the Add a Report Resource page, sales_fr.properties appears as the Selected Resource, indicating that the server automatically detected it as a resource bundle.

5. 「レポート リソースの追加」ページで、以下の情報を⼊⼒します。

On the Add a Report Resource page, enter this information:

「名前」欄には、”sales_fr.properties” と⼊⼒します。

Name – sales_fr.properties

「リソース ID」欄には、”sales_fr.properties” と⼊⼒します。

Resource ID – sales_fr.properties

リソース IDは正確に⼊⼒してください。

Enter the Resource ID field exactly as shown.

6. [次へ] ボタンをクリックします。

「コントロールとリソース」ページに戻ってきます。

Click Next.

The Controls & Resources page appears.

英語に翻訳した新しいリソースバンドルを作成するには:

1. テキストエディタで新しい英語翻訳⽤のファイルを作成し、⼊⼒コントロール⽤に以下の「名前 – 値」ペアを⼊⼒します。

In a text editor, create a new file for English translations, and enter these input control name-value pairs in the file:

department_multi=Select Department department_1=Work #1

department_2=Work #2 department_3=Work #3

2. ファイルの末尾に、ローカライズレポート⽤のフィールドとプロパティの翻訳を⼊⼒します。

At the bottom of the file, enter these field and property translations to localize the report:

title=Sales By Month Report sales.person=Sales person sales.account=Account sales.amount=Amount param.list=List item

3. そのファイルを、「sales.properties」という名前でハードディスクに保存します。

Save the file as sales.properties to your hard drive.

既存の英語リソースバンドルを新しいものに置き換えるには:

1. あなたがまだサーバにログインしているものと仮定して、「Sales By Month Report」を編集し、古い sales.properties リ ソースバンドルを削除します。

Assuming you’re still logged into the server and editing the Sales By Month report, remove the old sales.properties resource bundle:

a. 「コントロールとリソース」ページで、「sales.properties」を探します。

On the Controls & Resources page, select sales.properties.

b. [削除] をクリックします。

Click Remove.

2. [リソースの追加...] をクリックします。

Click Add Resource.

3. 「ファイル リソースの選択」ページで [ローカル ファイルをアップロード] を選択し、以前と同じ手順で、新しく作成 した「sales.properties」ファイルを開きます。

On the Locate File Resource page, select Upload a Local File, click Browse, and locate the new sales.properties file that you created in the previous procedure. Click Open.

4. [次へ] ボタンをクリックします。

「レポート リソースの追加」ページで、「選択されたリソース」欄に「sales.properties」が表示されます。これは、サー バがそのファイルは自動的にリソースバンドルとして検出できたことを示しています。

Click Next.

On the Add a Report Resource page, sales.properties appears as the Selected Resource, indicating that the server automatically detected it as a resource bundle.

5. 「レポート リソースの追加」ページで、以下の情報を⼊⼒します。

On the Add a Report Resource page, enter this information:

「名前」欄には、”sales.properties” と⼊⼒します。

Name – sales.properties

「リソース ID」欄には、”sales.properties” と⼊⼒します。

Resource ID – sales.properties

リソース IDは正確に⼊⼒してください。

Enter the Resource ID field exactly as shown.

6. [次へ] ボタンをクリックします。

Click Next.

7. 「コントロールとリソース」ページで、[送信] ボタンをクリックします。

この時点ではまだレポートを実⾏できません。理由は、sales.properties ファイルが、JRXML で定義されるすべてのパラ メータに対する「名前 – 組」ペアを含んでいないからです。

On Controls & Resources, click Submit.

At this point, the report doesn’t run because the sales.properties file doesn’t contain name-value pairs for all parameters that the JRXML defines. In the next procedure, you remove these parameters from the report.

サンプルレポートデザインから不要なパラメータを除去するには:

ここでは、iReport から JasperReports Serverプラグインを使ってサーバに接続し、レポート出⼒のヘッダに出⼒されるパラ メータ名と設定値のリストをタイトル領域から除去する⽅法について説明します。

In this procedure, you connect to the server from iReport using the JasperReports Server Plug-in, then you remove elements in the title band that lists parameter names and settings in the report output header.

1. iReport からサーバに接続します。詳細は「6.2iReport からサーバに接続する」(p.133)を参照してください。

Connect to the server from iReport, as described in section 6.2, “Connecting to the Server from iReport,” on page 102.

2. 「Repository Navigator」パネルで「Temp」フォルダと「Sales By Month Report」フォルダを展開し、「Sales By Month Jasper Report」をダブルクリックします。

すると、「Designer」タブに JRXML レポートが表示されます。

In the Repository Navigator, expand the Temp and Sales By Month Report folders, then double-click Sales By Month Jasper Report.

The JRXML report appears in the Designer tab.

3. Ctrlキーを押しながら、タイトル領域の要素 $R{title}, $R{param.list}, $P{ListInput} 以外を選択します。

図 3-34 に、その様子を示します。

Ctrl-click to select all elements in the title band except $R{title}, $R{param.list}, and $P{ListInput}.

Figure 3-34 shows the selected elements in the title band

ドキュメント内 JasperReports Server CP User Guide JP (ページ 73-83)