Configuring JasperReports Server to Offer a Locale

After creating a locale, you must configure JasperReports Server to offer it to your users, along with any new time zones.

The tasks in this section require you to edit these files:

File Name

Location

Purpose of Edits

applicationContext-security.xml

WEB-INF

Specifying additional locales

jasperserver-servlet.xml

WEB-INF

Specifying additional time zones

Specifying Additional Locales

By default, JasperReports Server appears in the locale selected in the end user’s browser. The Login page allows users to specify the locale they want to use. The list of available locales is defined in applicationContext-security.xml. Edit this file to add a new locale.

To add a new locale:

1. Edit the applicationContext-security.xml file and locate the bean named userLocalesList. For example:
<bean id="userLocalesList"
        class="com.jaspersoft.jasperserver.war.common.LocalesListImpl">
    <property name="locales">
        <list>
            <value type="java.util.Locale">en</value>
            <value type="java.util.Locale">fr</value>
            <value type="java.util.Locale">it</value>
            <value type="java.util.Locale">de</value>
            <value type="java.util.Locale">ro</value>
            <value type="java.util.Locale">ja</value>
            <value type="java.util.Locale">zh_TW</value>
        </list>
    </property>
</bean>
2. Add the new locale to the end of the list. For example, add the following line for Dutch (Java’s nl_NL locale):
            <value type="java.util.Locale">nl_NL/value>
3. Save the file.
4. Restart JasperReports Server, and log into the web application to test your translation. Reviewing the translated strings in context can help you improve your word choices.

For a list of Java-compliant locales, please refer to the Java web site.

Specifying Additional Time Zones

By default, JasperReports Server assumes the user’s time zone is that of the JasperReports Server host. The Login page allows users to choose a different time zone. The available list is defined in applicationContext.xml file.

To add a time zone:

1. Open the applicationContext.xml file and locate the userTimeZonesList bean. For example:
<bean id="userTimeZonesList"
        class="com.jaspersoft.jasperserver.war.common.JdkTimeZonesList">
    <property name="timeZonesIds">
        <list>
            <value>America/Los_Angeles</value>
            <value>America/Denver</value>
            <value>America/Chicago</value>
            <value>America/New_York</value>
            <value>Europe/London</value>
            <value>Europe/Berlin</value>
            <value>Europe/Bucharest</value>
        </list>
    </property>
</bean>
2. Add the new time zone to the bottom of the list. Specify each time zone as the standard Java time zone values so that JasperReports Server adjusts for daylight savings time when appropriate. For example, add the following line for Tokyo:
            <value>Asia/Tokyo</value>
3. Save the file.
4. Restart JasperReports Server.

For more information about Java-complaint time zones, please refer to the Java web site.

Setting a Default Time Zone

If you want JasperReports Server to use a time zone other than the host computer's, you can set a specific time zone in Java. It becomes the default time zone for all users, but they can still select a different time zone when they log in.

To set a default time zone, set the user.timezone property in the JVM as shown in the tables below. Locate the file containing JVM settings for your platform and application server. The value for the property must be a Java-compliant time zone, for example, Europe/Bucharest.

You must restart your application server for this setting to take effect. The time zone is set for all applications in your application server, including JasperReports Server.

JVM Settings for Default Time Zone

Operating System

App Server

File

Setting

Windows

Tomcat

<apache-tomcat>\bin\setenv.bat

Add this line of code:

set JAVA_OPTS=%JAVA_OPTS%
-Duser.timezone=<timezone>

JBoss

<jboss>\bin\run.bat

Linux

Tomcat

<apache-tomcat>/bin/setenv.sh

Add this line of code:

export JAVA_OPTS="$JAVA_OPTS
-Duser.timezone=<timezone>"

JBoss

<jboss>/bin/run.sh

Both

GlassFish

<glassfish>/domains/domain1/config/domain.xml

Add this line of code to <jvm-options> section:

-Duser.timezone=<timezone>

Version: 
Feedback