Introduction :
Jasper gives users the freedom of configuring the text, images and Input control labels according to the client language. This blog shows the process of localizing the reports by defining the exact translation of the text and input control labels in a particular file.
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Pr-requisites :
- Install Jasper reports Server 6.2
- Install Jaspersoft iReports Designer Professional 5.6.0
- Data source Mysql; Database used:- foodmart
Steps to create localized text field in a report :
Step 1: Create a Report in iReport
- Create a folder in a local file system and name it “iReports_Workspace” .
- Create a report in iReports, Blank A4 size and name it “Localisation_Jasper”, use MySQL as a data source and “foodmart” as a database.
- Query used :
select p.product_name,s.store_name,t.the_year,sl.store_sales,sl.store_cost,sl.unit_sales,t.the_month,
(sl.store_sales-sl.store_cost)as profits
from
store s
INNER JOIN
sales_fact_1997 sl ON sl.store_id=s.store_id
INNER JOIN
product p
ON p.product_id = sl.product_id
INNER JOIN
customer c
ON c.customer_id=sl.customer_id
INNER JOIN
time_by_day t
ON t.time_id=sl.time_id
where t.the_month like $P{MonthName} limit 100
4. Create a parameter “MonthName” create the fields as shown in the image given below.
5 . Select the text field and in the “text field properties” edit the “Text Field Expression” and write $R{localization.text1}.
6. In the iReports Inspector select the report and edit the properties of the main report, add the name of the “Resource Bundel” as “iReports_Workspace” . (Name of the folder where a report is saved).
7. Insert an image in the “Page Header” band of the report but do not select an image from any source. In the image properties change the “Image Expression” to “$R{image.flag}”.
Creating the Resource Bundle files :
Resource Bundle includes two files “iReports_Workspace.properties” and “iReports_Workspace_es.properties” .
iReports_Workspace.properties includes the text in English :
localization.text1=product name
MonthName=input control
image.flag = us.gif
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
iReports_Workspace_es.properties includes translated text in Spanish :
localization.text1=nombre del producto
MonthName=control de entrada
image.flag = sk.gif
“localization.text1 = product name” referes to the text in the text field. “MonthName = input control” referes to the Name of input control “image.flag = us.gif” is the name of the image file used.
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Publishing the report in Jasper server :
- Create the server connection in the Repository Navigator.
- Publish the report on the jasper server.
- Add input control to the report.
Input control ID : MonthName , Input control Name : $R{MonthName} ,
Input Control Details : SingleValue , Local Datatype : Text , id : Month , Name : Month
- Adding Resource Bundle :
- Right Click on the resources folder and add -> Resource Bundle , add the iReports_Workspace.properties and iReports_Workspace_es.properties .
2. Right Click on the resources folder and add -> Image, add the two images us.gif and sk.gif.
Verifying the above in Jasper Reports Server :
- Login to the Jaspersoft by selecting Locale as “en_US – English (United States)” and open the published report.
2 Check how the name of the Input control label is “input control” and image is us.gif and text below it is “product name”.
3. Logout from Jaspersoft and again login by selecting Locale as “es–Spanish”
4. Check how the name of the Input control label is “control de entrada” and image is sk.gif and text below it is “nombre del producto”.
Required image files :
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
Business Intelligence How do I change the serial number on my Jasper Report How do I sort data in Jasper report How do you add input controls in Jaspersoft report How to localize labels for Input Controls Jaspersoft Community Images and Input Control Labels in Jasper Reports Server Jasper iReport jasper server jaspersoft Localisation of Text open source BI Report Templates Generation and Management TIBCO JasperReports Server User Guide What is JasperReports server