Jasper Report Localization Customization
Objective
You want to provide localized versions of your Jasper reports.
Background
In Windchill Reports, there are both the Data Source and Report objects that contain text that can be localized. Localizing the text in these objects allows the text to be displayed in the locale you have configured.
Scope/Applicability/Assumptions
This documentation provides information about localizing Jasper Reports. The assumptions are:
You have access to create files in the source directory associated with <MyPackage> in <WindchillHome>.
You have created an Info*Engine task <MyTask> in its associated sub-directory <MyTaskPackage> in <WindchillHome>.
You have created the ReportTemplate, <MyReportTemplate> in the site context of <WindchillHome>.
You have created a Windchill Report object, <MyReport> in the site context.
You have created a Jasper Report <MyJasperReport>.jasper, under <WindchillHome>/codebase/JasperReports/<ReportFolder>.
You have created the related locale property files, under <WindchillHome>/codebase/JasperReports/<ReportFolder>.
For the WBR integration, you must also have access rights to update the reporting meta model. This document describes procedures for using standard Java resource bundles to externalize text used in the WBR system. To support localized text, a language-specific resource bundle must be created, with the text translated to the appropriate language. It is assumed that you require support for more than one language, and you have the ability to translate text to your supported languages. The text elements that are referred to in this document consist of report names, parameters, and columns. The actual data displayed in WBR reports is returned from Data Sources. Localizing this data is not covered in this document.
Intended Outcome
The result of this solution is the use of your WBR reports in more than one language based on the client locale.
Solution
Generating the external localized text to Java resource bundles that can be translated to support a specific client locale.
Prerequisite knowledge
To achieve this objective, you need to be familiar with the following:
Info*Engine User's Guide
JConsole User Interface
Report Management User Interface
Solution Elements
Element
Type
Description
<MyTask>
Info*Engine Task
The Info*Engine task for retrieving and manipulating Windchill data.
<MyTaskResource>
Resource Bundle Info Properties File
The resource bundle info file used to localize Info*Engine task text items.
<MyReportTemplate>WindchillReportTemplate
Windchill Object
The Windchill object that specifies a query for retrieving Windchill data.
<MyReportTemplateResource>
Resource Bundle Info Properties File
The resource bundle info file used to localize ReportTemplate text items.
<MyReport>WindchillReport
Windchill Object
The Windchill object that is displayed to the users in the Windchill user interface.
<MyReportResource>
Resource Bundle Info Properties File
The resource bundle info file used to localize Report text items.
Procedure - Localizing an Info*Engine Task Data Source
1. Create the file, <WindchillHome>/src/<MyPackage>/<MyTaskResource>.rbInfo. Add entries for the task method name, parameter names, and column names. Create the language-specific versions of <MyTaskResource>.rbInfo, and generate the associated Java source and compiled class files.
2. Edit the task XML file, <WindchillHome>/tasks/<MyTaskPackage>/<MyTask>.xml to specify the resource bundle. The following line should be added to the task comments:
{resouceBundle: <MyPackage>.<MyTaskResource> }
Procedure - Localizing a ReportTemplate Data Source
1. Create the file, <WindchillHome>/src/<MyPackage>/<MyReportTemplateResource>.rbInfo. Add entries, as necessary, for the task method name, parameter names, and column names. Create the language-specific versions of <MyReportTemplateResource>.rbInfo, and generate the associated Java source and compiled class files.
2. Update <MyReportTemplate> to specify the resource bundle. Navigate to the Windchill Site > Utilities.
3. Select <MyReportTemplate> and click Update to launch Query Builder.
4. Select the Report > Properties and enter <MyPackage>.<MyReportTemplateResource> into the Resource Bundle field.
5. Click OK and save the changes.
Procedure - Localizing a Windchill Report Object's Name
1. Create the file at the path<WindchillHome>/src/<MyPackage>/<MyReport>.rbInfo.
2. Add an entry for the Report Object's Name.
3. Create the language-specific versions of <MyReportResource>.rbInfo and generate the associated Java source and compiled class files.
5. Update <MyReport> to specify the resource bundle. Navigate to the Windchill Site > Reports page,
Select Edit for <MyReport>.
6. Enter <MyPackage>.<MyReportResource> into the Resource Bundle field and click OK.
7. Verify that the report attribute LocalizedName, is the translated text, based on the client locale.
Localizing a Jasper Reports
For localizing a Jasper report, refer to the JasperSoft documentation.
Assume that you have created related locale files, under <WindchillHome>/codebase/JasperReports/<ReportFolder>.
References:
Sample Code
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport xmlns = "http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://jasperreports.sourceforge.net/jasperreports
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name = "jasper_report_template" language = "groovy" pageWidth = "595"
pageHeight = "842" columnWidth = "555" leftMargin = "20" rightMargin = "20"
topMargin = "20" bottomMargin = "20" resourceBundle = "localizationdemo">
<title>
<band height = "552">
<textField>
<reportElement positionType = "Float" x = "150" y = "20"
width = "400" height = "50"/>
<textElement>
<font size = "24"/>
</textElement>
<textFieldExpression class = "java.lang.String">
<![CDATA[$P{REPORT_LOCALE}.getDisplayName ($P{REPORT_LOCALE})]]>
</textFieldExpression>
</textField>
<textField isStretchWithOverflow = "true" isBlankWhenNull = "true">
<reportElement positionType = "Float" x = "20" y = "125"
width = "530" height = "20"/>
<textElement textAlignment = "Justified">
<font size = "14"/>
</textElement>
<textFieldExpression class = "java.lang.String">
<![CDATA[$R{localization.text1}]]>
</textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Examples of Usage in Windchill Code
All out-of-the-box reports are localized for all Windchill supported locales.
Related Packages/Class Javadoc
Foundation module
wt.query.template
Reporting module
com.ptc.windchill
Other Related Windchill Documentation
Report Management online help
도움이 되셨나요?