This chapter shows how to incorporate internationalization while using the report designer. This allows the report designer to specify labels in the report template that will be substituted during report generation with values from the language appropriate properties file.
Externalize Label Strings
The first step is to externalize the strings required for the report. This is done by creating a properties file with the value of each property being the text you want to appear in the report. The name of each property will be used in the report definition.
...
In your favorite text editor, create a properties file named "MyReport.properties" and add the following name-value pairs:
Code Block |
---|
report.title=Sample Product Inventory Report label.1=Product Code label.2=Product Name label.3=Quantity |
Define the Resource Path
The report template needs to know where it will be able to find the properties files that will be used as a resource for localized strings.
...
In the Properties pane, specify the directory in which the MyReport.properties file was saved.
Add Resource Labels
The resource labels defined on the report will look in the resource files (in the report's resource path) when the report is generated. The resource key of the resource label is the property name for this lookup.
...
Again, click on the Preview button to see that the system found and substituted the proper labels.
...
Create Localized Resource Files
If the report needs to be translated to different languages, more resource files (properties files) need to be created (- one per language).
Since the base properties file was created in English, we can create the English properties file by copying MyReport.properties to MyReport_en.properties (in the same directory).
If we need to translate the report Frenchto German locale for Switzerland, create the properties file (in the same directory) with the name MyReport_frde_FRCH.properties and translate the property values to FrenchGerman. (NOTE: only the property values ... the property
names need to be the same in all the properties files for the substitution to occur correctly).
...