Creating a Locale

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
<js-install>/buildomatic/conf_source/ie Pro /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
.properties

Labels and messages for the Create Domain dialog.

domain_designer_messages
.properties

Labels and messages for the Domain Designer UI.

HomeBundle.properties

Labels for the home page.

image_descriptions_messages
.properties

Labels and messages for the AWS (Amazon Web Services) machine images.

jasperreports_highcharts_
messages.properties

Messages for charts in the report viewer.

jasperreports_messages
.properties

Labels and messages for the report viewer.

jasperserver_config.properties

Configuration properties for date formats and email templates.

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
logger_descriptions_pro.properties

Internal log messages.

pro_nav_messages.properties

Labels and messages for the menu bar and 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
.properties

Labels and messages for the report options dialog.

ScalableInputControlsBundle
.properties

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

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

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

    Procedure
  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:

date.format=dd-MM-yyyy
datetime.format=dd-MM-yyyy HH:mm
calendar.date.format=%d-%m-%Y
calendar.datetime.format=%d-%m-%Y %H:%M

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.

For some locales, you can use a different (non-default) Date/Time format. However, this format is not applied for Input Controls, because the date format for Input Controls is a constant and is set to ISO date/time format (your date and your calendar settings are ignored for Input Controls).

If your existing configurations for Input Controls and your locales are working fine, then no changes are needed and JasperReports Server will proceed sending or getting date/datetime in ISO format as before.

If you prefer to not have Input Controls operating only in ISO date format (for example, when Input Controls are used in Visualize.js implementation), you can enable the new provider added in this release and re-save ad-hoc views/reports if needed.

To use the date/format from jasperserver_config.properties for Input Controls, apart from setting formats found in the config.properties file, perform the following steps:

    Procedure
  1. Update the "jasperserver_config.properties" file.
  2. Update the /WEB-INF/js.spring.properties file:
    1. Comment out `bean.calendarFormatProvider=isoCalendarFormatProvider` line.
    • Uncomment `bean.calendarFormatProvider=messagesCalendarFormatProvider` line.

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

ADH_100_MASK_date_0 = short,hide
ADH_100_MASK_date_1 = long,hide
ADH_100_MASK_date_2 = short,medium
ADH_100_MASK_date_3 = medium,medium

ADH_100_MASK_int_0 = #,##0
ADH_100_MASK_int_1 = 0
ADH_100_MASK_int_2 = $#,##0;($#,##0)
ADH_100_MASK_int_3 = #,##0;(#,##0)

ADH_100_MASK_dec_0 = #,##0.00
ADH_100_MASK_dec_1 = 0
ADH_100_MASK_dec_2 = $#,##0.00;($#,##0.00)
ADH_100_MASK_dec_3 = $#,##0;($#,##0)

3/31/09
Mar 31, 2009
March 31, 2009
Mar 31, 2009 23:59:59

-1,234
-1234
($1,234)
(1234)

-1,234.56
-1234
($1,234.56)
($1,234)

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:

ADH_100_MASK_dec_4

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:

Supporting a different currency than USD involves changing the monetary masks to use the correct symbol for your currency (for example, replace the $ symbol in the ADH_100_MASK_dec_2 and ADH_100_MASK_dec_3 masks). However, changing this symbol does not actually convert currencies in your reports.
Supporting other currencies in addition to USD involves adding new masks. However, adding data formats does not actually convert currencies in your reports.
Supporting currency conversion is more complicated; you must consider such issues as fluctuations in conversion rates. Oftentimes, a third-party service can be used to perform currency conversion