JasperServer and iReport Internationalization Tutorial
Introduction
Internationalization is quickly becoming a growing requirement for many companies as they expand their offices to various locations around the world. Many companies are searching for a robust BI platform with multi-language support. This tutorial will identify various areas within the Jaspersoft Business Intelligence suite that utilize internationalization.
Note: To follow along with the example scenario, download the sample files located here.
Objectives
This guide will enable you to:
- Understand the 'bundles' concept
- Modify JasperServer bundle (to upgrade a translation)
- Implement a new language
- Internationalize Domains
- Internationalize reports
Pre-Requisites
Install the JasperServer samples on your JasperServer installation.
Understanding the 'Bundles' Concept
|
The concept of internationalization is the same across JasperServer UI, reports, and Domains. In order to understand the concept of internationalization, first review the concept of bundles, which is a key building block.
Name_Suffix.properties
Notes:
|
Modifying JasperServer Bundles
Locale bundles that use Unicode, accents or special characters have to be coded like \u00e0 for à.
| Step | Action |
| 1 | Go to the …\jasperserver-pro\WEB-INF\bundle directory |
| 2 |
All properties files are organized by application name for easy access. Example: Edit adhoc_messages_fr.properties file as follows, (located in the folder you downloaded above) and then save it.
|
| 3 |
Check the result: a. Log into JasperServer as jasperadmin / jasperadmin. b. Go to Create > Ad Hoc Report You should see the following: on the left side the original translation, and on the right the modified one Tip: Internationalization can be used for formatting of dates and numeric values. Edit the adhoc_masks_XX.propeties file to define additional translations.
|
Implementing a New Language
To implement a new language, copy all default bundles and rename them using the country code of your new language.
Example: In this example we will be defining translations for Danish. The country code is da (alpha-2 code).
| Step | Action |
| 1 | Go to the …\jasperserver-pro\WEB-INF\bundle directory, and open the file adhoc_messages.properties |
| 2 |
Rename (use Save As) the file to: adhoc_messages_da.properties Edit the file as follows in the image below:
|
|
3 |
Create a new entry for your language: a. Stop JasperServer b. Go to the …\jasperserver-pro\WEB-INF directory c. Edit the file ApplicationContext-Security.xml d. Localize the bean (approx line 176): <beanid="userLocalesList"class="com.jaspersoft.jasperserver.war.common.LocalesListImpl"> <property name="locales"> <list> e. Add your language in the list:
a. Start JasperServer b. Go to the login page select the new language c. Click Show locales and timezone to display the list
a. Log into JasperServer as jasperadmin / jasperadmin b. Go to Create > Ad Hoc Report c. View the result:
|
Internationalizing Domains
Prior to internationalizing Domains, you first want to finalize and publish the Domain to JasperServer. In general, translations are typically defined once the Domain is complete and validated.
Example: We create the default translation and the French translation for a Domain.
| Step | Action |
| 1 |
a. Log into JasperServer as jasperadmin / jasperadmin b. Go to View > Repository |
| 2 |
a. Select the Domain folder b. Click the Add Resource > Domain icon c. In Data Source section, click Browse, then select Organization > Analysis Components Analysis Data Sources > Foodmart Data Source d. Click OK e. In the Properties section, Display Name field, enter: employee_domain f. In the Design section, click the Upload tab, then select the provided file (domain_schema.xml) |
| 3 |
Launch the Domain Designer a. Select the Edit tab. b. Click Launch Domain Designer … c. In the top-right corner click the Export Bundle Stub icon
The following window appears: check the Autogenerate Key label box to get the labels keys Optionally, check the Autogenerate Key description box if you wish to generate a description
This will generate all the keys needed to create the bundle. Download the file and save it to your drive Best Practice: Change the name to the Domain’s name Example: Rename it to: employee_domain.properties
|
| 4 |
The initial export will serve as the default translation. Additionally, we will define a French translation.
Example: Translate the bundle into French and save it as employee_domain_fr.properties
|
| 5 |
Publish the translation to JasperServer: a. Log into JasperServer as jasperadmin / jasperadmin b. Go to View > Repository c. Select the Domain folder and then the Domain “employee_domain” d. Right click and choose Edit |
| 6 | Select Resources breadcrumb at the top of the screen, and then click Add Local Bundle |
| 7 |
a. On the Local File tab, find the employee_domain.properties and upload it. b. Click OK |
| 8 | Redo Step 7 for the file employee_domain_fr.properties |
| 9 |
Check your results: a. Log into JasperServer as jasperadmin / jasperadmin b. Go to Create > Ad Hoc Report c. Create a new Ad Hoc report using your new Domain
Note: Make sure to specify the appropriate locale.
|
Internationalizing Reports
Internationalizing Reports follows the same concept as internationalizing Domains. All labels that need to be translated are declared: $R {key_name}
Once the layout of the report has been finalized, create a bundle containing all the keys and their values (translations).
Example: We translate a report to French.
| Step | Action |
| 1 | Open iReport |
| 2 |
Create a new empty report.
a. Add a text field $R{hello} b. In the Report Inspector, right click on report name then select Properties. c. In resource bundle set Resource Bundle to localereport
d. Create the localereport.properties file: Hello=Hello word Translate the text as required, and save it as localereport_fr.properties: Hello=Bonjour a tous |
| 3 | Publish the report using the JasperServer plugin. |
| 4 |
Once the report is published, open the report unit, right click on the Resources folder, then choose Add > Resource Bundle
|
| 5 |
Complete the Import Resource screen the form as follows; ensure you provide the full name.
|
| 6 |
Repeat this for all languages using the example: localereport_fr.properties |
What's Next?
Resource for searching all language codes is here.
Tip: Select by alpha- codes.
Written By
This tutorial was written by Guillaume Autier, Sales Engineer, June 2009
Language














>