The server provides linguistic support for the 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) |
In the figure A Multi-select List of Values in English and Spanish, there is 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.
A Multi-select List of Values in English and Spanish |
|
The next example shows how to localize an input control that presents a single-select list of values. These tasks are explained step-by-step:
| • | Add a multi-lingual static list of values to a list input control. |
| • | 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 a multi-lingual list of values in an input control. |
You edit a sample report to localize the list input control. To the list input control, you add a multi-lingual list of values for the US English and French locales.
To add a multi-lingual static list of values to a list input control:
| 1. | Log into the server as administrator and add a folder to the repository named Temp. |
| 2. | Locate the Sales By Month report in the Reports > Samples folder of the repository. Select it and click Copy. |
| 3. | Navigate to the Temp folder and choose Paste. The Sales By Month Report appears in the Temp folder. |
| 4. | Select the Sales By Month Report and click Edit. |
The JasperReport wizard appears.
| 5. | Click Controls & Resources. |
The report has five input controls, including a List Input Control, two resource bundles, and other resources, as shown in Input Controls and Resources.
| 6. | Click the List Input Control to edit it. |
| 7. | In Locate Input Control, click Next. |
| 8. | On the Create Input Control page, change the prompt text from List Input Control to $R{department_multi}. |
In the figure A $R Expression in the Prompt Text Field, the $R expression is in the Prompt Text field.
A $R Expression in the Prompt Text Field |
|
| 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: |
Name | Value |
$R{department_1} | 1 |
$R{department_2} | 2 |
$R{department_3} | 3 |
the figure The Revised List of Values Containing $R Expressions shows the edited list of values containing the $R expressions in the name fields.
The Revised List of Values Containing $R Expressions |
|
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. |
To create a new resource bundle for the French translations:
| 1. | In a text editor, create a new file for French translations, and enter these name-value pairs for the input control: |
| 2. | At the bottom of the file, enter these field and property translations to localize the report: |
| 3. | Save the file as sales_fr.properties to your hard drive. |
To upload the French resource bundle:
| 1. | Assuming you are still logged into the server, select the Sales By Month report, and click Edit. |
| 2. | On the Controls & Resources page, click Add Resource. |
| 3. | 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. | 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: |
| • | Name – sales_fr.properties |
| • | Resource ID – sales_fr.properties |
The Controls & Resources page appears.
To create a new resource bundle for the English translations:
| 1. | In a text editor, create a new file for English translations, and enter these input control name-value pairs in the file: |
| 2. | At the bottom of the file, enter these field and property translations to localize the report: |
| 3. | Save the file as sales.properties to your hard drive. |
To replace the old English resource bundle in the repository with the new one:
| 1. | Assuming you are still logged into the server and editing the Sales By Month report, remove the old sales.properties resource bundle: |
| a. | On the Controls & Resources page, select sales.properties. |
| 3. | 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. |
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: |
| • | Name – sales.properties |
| • | Resource ID – sales.properties |
| 7. | On Controls & Resources, click Submit. |
At this point, the report does not run because the sales.properties file does not contain name-value pairs for all parameters that the JRXML defines. In the next procedure, you remove these parameters from the report.
To remove unwanted parameters from the sample report design:
This procedure assumes you finished procedures in Adding Multi-lingual Prompts to Input Controls and are still connected to the server from iReport using the JasperReports Server Plug-in. In this procedure, you remove elements in the title band that lists parameter names and settings in the report output header.
| 1. | In the Repository Navigator, expand the Temp and Sales By Month Report folders, then double-click |
The JRXML report appears in the Designer tab.
| 2. | Ctrl-click to select all elements in the title band except $R{title}, $R{param.list}, and $P{ListInput}. |
In the figure Selecting Elements to Remove from the Title Band, the selected elements are in the title band.
Selecting Elements to Remove from the Title Band |
|
| 3. | Right-click an empty area in the Designer tab, and choose Delete. If you have empty elements after the last step, delete them. |
In the figure Elements Remaining in the Title Band, the remaining elements are displayed.
Elements Remaining in the Title Band |
|
There’s too much white space in the title band.
| 4. | To remove excess white space: |
| a. | Drag a selection box around the $R{param.list} and $P{ListInput} elements. |
| b. | Press the Arrow key on the keyboard to move the elements upward. |
| c. | Drag the bottom margin of the title band upward to reduce its height. |
| 5. | Remove the actual parameters from the report: |
| a. | Choose Window > Report Inspector. |
| b. | In the Report Inspector, expand Parameters, scroll to the bottom of the parameter list, and Ctrl-click to select these parameters: |
| c. | Right-click the selected parameters and select Delete. |
Deleting Unwanted Parameters From the JRXML |
|
| 6. | Click Yes to confirm that you want to delete the items. |
| 7. | From iReport, remove the input control resources from the report unit in the repository. |
| a. | In the Repository Navigator, expand Input Controls in the report unit Sales By Month Report. |
Expanding the Input Controls Folder |
|
| a. | Ctrl-click to select these input control resources: |
| b. | Right-click the selected resources and click Delete |
Answer Yes to each prompt to confirm the deletion of the resource.
| 8. | Right-click the Sales By Month Jasper Report JRXML, and choose Replace with Current Document. |
Saving the Modified JRXML to the Repository from iReport |
|
| 9. | Click Yes when asked if you want to save the file before sending its content to the server. |
| 10. | Click View > Repository, navigate to the Temp folder, and select the Sales By Month Report. Click Edit. |
In the figure Controls & Resources Listing Only One Input Control, the JasperReport wizard on the server, only one input control remains in the report.
Controls & Resources Listing Only One Input Control |
|
To run the report that uses a multi-lingual list of values:
| 1. | Click LogOut. On the server login page, click Show locale & time zone, select the en_US-English (United States) locale, and log into the server as an administrator. |
| 2. | Navigate to the Temp folder of the repository, and click the name of the Sales By Month Report to run the report. |
The report viewer presents the report using English field and property names in the report.
| 3. | Click Options, and select the drop-down. |
The prompt and list of values appear in English, as shown in A List of Values in English and French.
| 4. | Logout, on the server login page, click Show locale & time zone, select the fr_French locale, and log into the server as an administrator. |
| 5. | Navigate to the Temp folder of the repository, and click the name of the Sales By Month Report to run the report. |
In the figure Viewing Report Output for the French Locale, the report output displays: the French report title, field, and property names defined in the resource bundle. The server formats the currency using a comma instead of a decimal point to separate Euro cents from dollars. Translation packs and resource bundles installed with the server for the French locale are used to format currency and dates and to translate web interface components.
Viewing Report Output for the French Locale |
|
| 6. | Click Options, and select the drop-down. The input control prompt and static list of values appears in French. |
In the figure A List of Values in English and French, you can see the input control prompt and static list of values in English and in French.
A List of Values in English and French |
|
Recommended Comments
There are no comments to display.