iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideFigure 16-23 A second field has been added in the measure cell to show the percentageFigure 16-24 The final report with percentages included322

InternationalizationCHAPTER 17 INTERNATIONALIZATIONInternationalization is the process by which applications are made acceptable for multiple cultures. The most important changethat should be made to an application is the language of the UI and output. This part of internationalization is generally called“localizing.” In iReport, localizing a report requires making all static text that is set at design time, such as labels andmessages, adaptable to locale options at run time; the report engine will print the text using the most appropriate availabletranslation. The text translations in the different languages supported by the report are stored in resource files called “resourcebundles.” This chapter covers localizing reports and explains using the built-in function msg() to localize very complexsentences created dynamically.This chapter has the following sections:• Using a Resource Bundle Base Name• Retrieving Localized Strings• Formatting Messages• Deploying Localized Reports• Generating a Report Using a Specific Locale and Time Zone17.1 Using a Resource Bundle Base NameWhen you internationalize a report, it’s necessary to find all the display text included in the report design that needs to becustomized, such as labels and static strings. A key (a name) is associated with every text fragment and is used to recall thesefragments. These keys and the relative text translation are written in special files (one per language). Below is an example of atext localization mapping file:Title_GeneralData=General DataTitle_Address=AddressTitle_Name=NameTitle_Phone=PhoneAll files containing this information have to be saved with the .properties file extension. The effective file name (that is,the file name without the file extension and the language/country code, which you will see later in this section) represents thereport Resource Bundle Base Name (for example, the Resource Bundle Base Name for the resource filei18nReport.properties is i18nReport). When you generate an instance of the report, the report engine will look in theclasspath for a file that has the Resource Bundle Base Name plus the .properties extension (so, for the previous example, itwill look for a file named i18nReport.properties). If the report engine cannot find the file, it uses the default mapping323

InternationalizationCHAPTER 17 INTERNATIONALIZATIONInternationalization is the process by which applications are made acceptable for multiple cultures. The most important changethat should be made to an application is the language of the UI and output. This part of internationalization is generally called“localizing.” In <strong>iReport</strong>, localizing a report requires making all static text that is set at design time, such as labels andmessages, adaptable to locale options at run time; the report engine will print the text using the most appropriate availabletranslation. The text translations in the different languages supported by the report are stored in resource files called “resourcebundles.” This chapter covers localizing reports and explains using the built-in function msg() to localize very complexsentences created dynamically.This chapter has the following sections:• Using a Resource Bundle Base Name• Retrieving Localized Strings• Formatting Messages• Deploying Localized Reports• Generating a Report Using a Specific Locale and Time Zone17.1 Using a Resource Bundle Base NameWhen you internationalize a report, it’s necessary to find all the display text included in the report design that needs to becustomized, such as labels and static strings. A key (a name) is associated with every text fragment and is used to recall thesefragments. These keys and the relative text translation are written in special files (one per language). Below is an example of atext localization mapping file:Title_GeneralData=General DataTitle_Address=AddressTitle_Name=NameTitle_Phone=PhoneAll files containing this information have to be saved with the .properties file extension. The effective file name (that is,the file name without the file extension and the language/country code, which you will see later in this section) represents thereport Resource Bundle Base Name (for example, the Resource Bundle Base Name for the resource filei18nReport.properties is i18nReport). When you generate an instance of the report, the report engine will look in theclasspath for a file that has the Resource Bundle Base Name plus the .properties extension (so, for the previous example, itwill look for a file named i18nReport.properties). If the report engine cannot find the file, it uses the default mapping323

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!