When you want to create other locales for JasperReports Server, translation is only one aspect of localization. Creating a locale includes these tasks:
• | Translating labels and messages |
• | Creating a Resource Bundle |
• | Setting Date and Datetime Formats |
• | Setting Data Format Masks |
The tasks in this section require you to edit these files:
File | Location | Purpose of Edits |
*.properties files | .../WEB-INF/bundles | Translating labels and messages |
jasperserver_config.properties | .../WEB-INF/bundles | Changing date formats |
adhoc_masks | .../WEB-INF/bundles | Changing format masks |
About Properties Files
Resource bundles for JasperReports Server and Jaspersoft OLAP are Java properties files found in the .../WEB-INF/bundles directory. The properties files contain all the labels and messages used in JasperReports Server and Jaspersoft OLAP.
A bundle includes a default locale (for example, jasperserver_messages.properties), which is written in U.S. English. Then it consists of all the properties files with the same base name, but different locale (such as jasperserver_messages_fr.properties). Each file translates all of the strings of the default file into the language given by the locale. The Java programming language has rules for specifying locales and alternate locales and determining which locale in the bundle to use.
Default Resource Bundles in JasperReports Server | |
File in .../WEB-INF/bundles | Description |
accessibility_messages.properties | Text spoken in accessibility software such as screen readers. |
AdHocFiltersBundle.properties | Labels and messages for the Ad Hoc Filters panel. |
adhoc_masks.properties | Masks (data formats) for values appearing in the Ad Hoc Editor. |
adhoc_messages.properties | Labels and messages for the Ad Hoc Editor. |
AttributeBundle.properties | Messages for attribute validation. |
AttributeBundles.properties | Messages for attribute dialogs. |
calendar.properties | Labels and messages used by the pop-up calendar dialog. |
.properties | . |
CommonBundle.properties | Bundle for tests. |
createsldatasource_messages | Labels and messages for the Create Domain dialog. |
domain_designer_messages | Labels and messages for the Domain Designer UI. |
HomeBundle.properties | Labels for the new home page introduced in version 5.5. |
image_descriptions_messages | Labels and messages for the AWS (Amazon Web Services) machine images. |
jasperreports_highcharts_ | Messages for charts in the report viewer. |
jasperreports_messages | Labels and messages for the report viewer. |
jasperserver_config.properties | Configuration properties for dates and date-times. |
jasperserver_messages.properties | Labels and messages used in the main JasperReports Server user interface. |
jsexceptions_messages.properties | Messages used in errors and exceptions, both in the UI and in the log messages. |
LicenseMessages.properties | Labels and messages used when validating licenses. |
logger_descriptions.properties | Internal log messages. |
pro_nav_messages.properties | Labels and messages for the menu bar and old Home page. |
querybuilder_messages.properties | Labels and messages for the Choose Data dialog (for creating a Domain Topic before using Ad Hoc Editor). |
report_option_messages | Labels and messages for the report options dialog. |
ScalableInputControlsBundle | Labels for lists of values in input controls. |
scheduling_ws.properties | Validation messages for the report scheduler. |
security.properties | Messages used by input validation. |
semanticLayer.properties | Labels and messages for the Domain designer and Ad Hoc data policies. |
ValidationBundle.properties | Messages for dashboard dialogs. |
Default Resource Bundles in Jaspersoft OLAP | |
File in .../WEB-INF/bundles | Description |
ja_mondrian.properties | Labels and messages in the OLAP settings UI. |
ja-pro_messages.properties | Labels and messages in the commercial edition OLAP viewer. |
jpivot_messages.properties | Labels and messages in the community edition OLAP viewer. |
mondrian_exception_messages | MDX validation error messages specific to the internal analysis engine. |
The standalone import and export tools have their own bundles located outside of the web app. The following bundles are located in the WAR file distribution package, under the buildomatic folder.
Default Resource Bundles for js-export.sh and js-import.sh | |
File in buildomatic/conf_source/ieCe/bundles | Description |
---|---|
File in buildomatic/conf_source/iePro/bundles | Description |
ji-export-messages.properties | Labels and messages for js-export --help. |
multi-tenancy-export-messages.properties | Labels and messages for export in commercial editions. |
multi-tenancy-import-messages.properties | Labels and messages export in commercial editions. |
jsexceptions_messages.properties | Messages used in errors and exceptions, both in the UI and in the log messages. |
If you use the JasperReports Server portlet to display JasperReports Server content in a portal (such as Liferay), the deployed portlet includes properties files, as well:
File | Location | Description |
jaspersoft_portlet_ | .../WEB-INF/bundles under the location where the portlet is deployed. For example: C:liferaywebapps<portlet_context_name>WEB-INFbundles (where <portlet_context_name> is the name specified when the JasperReports Server portlet was deployed). | Labels and messages that appear in the portlet, including the help text. Note that this does not include text in specific reports; to localize the report's content, you must upload its resource bundle to the repository. |
Creating a Resource Bundle
Create a resource bundle by making a copy of each *.properties file, using the following syntax for the copy's file name:
<default_file_name>_<locale>.properties
where
<default_file_name> is the name of the default version of the properties file, and
<locale> is a Java-compliant locale identifier.
For example, consider the core JasperReports Server resource bundle. For various locales, it might be named as follows:
Language | File Name |
Default (English) | jasperserver_messages.properties |
French | jasperserver_messages_fr.properties |
French in Switzerland | jasperserver_messages_fr_CH.properties |
For a list of Java-compliant locales, please refer to the Java documentation.
The resource bundles described in this document consist of locale-specific Java properties files. Java properties files use the ISO-8859-1 (Latin-1) encoding that is the same as ASCII for all English non-accented characters. For international characters that are not in ISO-8859-1, use Unicode escape sequences (for example u00e9 is é). |
To create a new JasperReports Server resource bundle:
1. | Copy each of the properties files (keeping them in the same directory as the originals) and rename them according to your locale. |
2. | Translate each *.properties file's labels and messages into the new language. |
Some of the strings in the properties files are date formats and format masks that may need to be edited for the new locale. For more information, refer to Setting Date and Datetime Formats.
3. | Save the files. |
4. | If the new locale requires specific character encoding or fonts, ensure that JasperReports Server and the third party software it relies on are configured to support them. For more information, refer to Configuring JasperReports Server for Multibyte Fonts. |
The new locale is not available in JasperReports Server until you follow the steps described in Specifying Additional Locales. |
Setting Date and Datetime Formats
Each locale may have its own rules for displaying dates and datetime values. System date and datetime formatting is controlled by four patterns that are specified in the jasperserver_config_<locale>.properties file associated with a particular locale.
For example in the English resource bundle, the four entries are:
The first two keys are used to parse and format dates and datetime values using an internal java.util.DateFormat object across the whole application. These patterns should be non-localized date patterns, in accordance with the Java Development Kit (JDK) syntax.
The other two keys are used by the calendar control, which formats the user-selected date and datetime values in accordance with its own pattern syntax.
To change the system date and datetime formatting for a new locale, edit the strings specified by these keys.
Setting Data Format Masks
Each locale may have its own format masks that determine how numbers appear in the Ad Hoc Editor. To make the data format masks vary by locale, you must create an adhoc_masks file for the new locale. To do so, copy the file adhoc_masks.properties to a new name that specifies the new locale and change the masks defined in the new file. For example, the French file would be named adhoc_masks_fr.properties.
The data format masks described in this section are used in the Domains and in the Ad Hoc Editor; they appear in Ad Hoc views as well as JRXML reports based on Domains. They're not applicable to Jaspersoft OLAP. |
Customize the available data format masks for dates, integers, and decimals by editing the existing masking entries or adding new ones. The default entries are given in the following table:
Data Format Mask Properties | Appearance in en_US Locale |
3/31/09 -1,234 -1,234.56 |
The data format masks for each type are numbered consecutively from zero; create new masks by adding new entries. The keys of the new entries must follow the convention established in the default entries. For example, a new decimal data format mask might have this ID:
Date format masks are implemented using java.text.SimpleDateFormat and JasperReports extensions that provide access to predefined localized data format masks. New datetime masks must be specified in one of the following formats:
• | A style for the date part of the value and a style for the time part (separated by comma) or a single style for both parts. A style is one of Short, Medium, Long, Full, Default (which correspond to java.text.DateFormat styles) and Hide. |
• | A pattern that can be supplied to java.text.SimpleDateFormat. In this case, internationalization support is limited. |
Both integer and decimal data format masks are implemented with java.text.DecimalFormat, which localizes characters in the format specification. For example, consider the case of the digit grouping symbol (thousands separator): in French, it is a space; in U.S. English, it is a comma. DecimalFormat handles both cases: if the number pattern #,##0 is used, the number 6000 appears as 6 000 in the French locale and as 6,000 in the U.S. English locale.
For more information about Java's handling of decimal and date format masks, see:
• | http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html |
• | http://download.oracle.com/javase/6/docs/api/java/text/DateFormat.html |
By default, monetary values in Ad Hoc views are masked as USD (United States Dollars). Depending on your data, you may need to support a different currency, support more than one currency, or support currency conversion. These are three very different cases:
|
Recommended Comments
There are no comments to display.