Localisation of Text, Images and Input Control Labels in Jasper Reports Server

Posted on by By admin, in Business Intelligence, Jaspersoft, Open Source Business Intelligence | 0

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.

Get your 30 Days Trail Version

Pr-requisites :

  1. Install Jasper reports Server 6.2
  2. Install Jaspersoft iReports Designer Professional 5.6.0
  3. Data source Mysql; Database used:- foodmart

Steps to create localized text field in a report :

Step 1: Create a Report in iReport

  1. Create a folder in a local file system and name it “iReports_Workspace” .
  2. Create a report in iReports, Blank A4 size and name it “Localisation_Jasper”, use MySQL as a data source and “foodmart” as a database.
  3. 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.

iReports_Image

5 . Select the text field and in the “text field properties” edit the “Text Field Expression”  and write $R{localization.text1}.

iReports_Image_2

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).

iReports_Image_3

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.

Grab The 30 Days Free Trail

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.

Lets Start 30 Days Free Trail

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.

iReports_Image_5

Input control ID : MonthName , Input control Name : $R{MonthName} ,

Input Control Details : SingleValue , Local Datatype : Text , id : Month , Name :  Month

  • Adding Resource Bundle : 
  1. Right Click on the resources folder and add -> Resource Bundle , add the iReports_Workspace.properties and iReports_Workspace_es.properties .

iReports_Image_6

2. Right Click on the resources folder and add -> Image, add the two images us.gif and sk.gif.

iReports_Image_7

 

Verifying the above in Jasper Reports Server :

  1. Login to the Jaspersoft  by selecting Locale as “en_US – English (United States)” and open the published report.

iReports_Image_8 iReports_Image_9

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”

iReports_Image_10 iReports_Image_11

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 :

sk us

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

 

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments