Chapter 9. Internationalization

9.1. Internationalizing ERES

ERES provides many different features that enable you to generate reports for just about any locale and language. Different internationalization features can require different system or setting configurations depending on your specific requirements.

9.1.1. Specifying Locales

ERES allows reports and charts to have different time zones and locales. They are not limited to the locale on the machine where they are created. The locale can be set through the API immediately before the report or chart is run.

9.1.1.1. Locale-Specific Formatting

For data formatting (date and numeric), ERES allows you to set locale-specific formatting for report elements. Locale-specific formatting allows data elements to be displayed in the correct format for the particular locale that is being used for the report. Locale-specific options are available in the data formatting dialog for Report Designer (see Section 3.3.7.3 - Data Formatting for Formulas and Column Fields).

The locale for report and charts, as well as the time zone, can be set at run-time through the API. Note that this only effects the date, the time, and the data formatting.

9.1.1.2. Setting Time Zones and Locales Using the API

To set the time zone or locale, you can use the methods in QbReport/QbChart (applies to the entire report/chart) or use LocaleDateTimeFormat and LocaleNumericFormat objects (applies to a specific object in the report/chart). The following code fragments show how to do this with the two different approaches.

report.setLocale(Locale.UK);
report.settime zone(time zone.gettime zone("GMT"));
        

Full Source Code

Exported Results

Here, the formats are applied to the entire report. Alternatively, you can apply the format to specific data columns as follows:

LocaleNumericFormat currencyFormat = LocaleNumericFormat.getCurrencyInstance();
currencyFormat.setLocale(Locale.UK);
int columnIndex = 2; //column 2 is the "Unit Price" column
report.getTable().getColumn(columnIndex).setDataFormat(currencyFormat);

LocaleDateTimeFormat dateFormat = LocaleDateTimeFormat.getDateInstance();
dateFormat.settime zone(time zone.gettime zone("GMT"));
report.getPageFooter().getData(1).setDataFormat(dateFormat);
        

Full Source Code

Exported Results

9.1.2. Language and Encoding

ERES includes a set of features that removes limitations caused by language differences. By utilizing a simple to use interface, it is possible to translate all the text, buttons, and menus within ERES to a different language. Through some basic configuration, you will be able to import, view, and type characters in a foreign language, as well as save and export reports in that language.

9.1.2.1. ERES Language Translation

Internationalization is supported through the use of an .xml file, ERES_Language.xml (located in the <ERES installation directory>). A GUI is provided to work with the ERES_Language.xml file and replace the lines of English with those of another language.

The ERES_Language.xml file has the following structure:

<Product name="REPORTDESIGNER" dir="quadbase/reportdesigner/designer">

      <File name="ReportMenubar.java">
            <CODE>File</CODE>
            <TEXT>File</TEXT>
            <CODE>New</CODE>
            <TEXT>New</TEXT>
            ... </File> 

</Product>
        

The file has the following tree structure: Product (Directory)Filetext. You can easily search the product, file, or text you want to translate and simply replace the Text between <Text> and </Text> with the translation. ERES will replace <Code> with <Text> in the Java Swing UI and/or in the ERES web application. The translation GUI will list all the products and each product will list the codes that need translation. A same code, (for example, File) may be listed under several products to maintain the completeness of each product. However, the translation for a code is duplicated across all products. The same code cannot have two different translations for different products.

The ERES_Language.xml file is located in the install directory. It is recommended that you make a copy (of ERES_Language.xml) and then use the GUI provided (on the copy) to put in the translation without touching the xml file directly. To utilize the user interface, navigate to the ERES root directory and enter the following command:

java -classpath "./lib/ERESOrganizer.jar;.;" quadbase.internationalization.TranslateWizard -file:<fileName> -enc:<encoding>
        

where <fileName> represents the xml file that will store the translation and <encoding> represents the encoding for the translation. For correct results, the proper encoding must be specified. If the file name and encoding are not provided, the default file name (ERES_Language.xml) and default encoding (Cp1252) will be used.

An example of the above command is given below:

java -classpath "./lib/ERESOrganizer.jar;.;" quadbase.internationalization.TranslateWizard -file:Chinese.xml -enc:Big5
        

Where Big5 is the encoding used to save Chinese.xml file.

When the Translate wizard is started, it appears as below:

Translate Wizard

You can see the various codes (available for translation) by selecting appropriate Product. Products are shown in a tree on the left that contains all the files available for translation. For example, on the image below you can see expanded QUERYBUILDER product. You may either translate entire product by selecting the product node or just select a file that you want to translate.

Insert Translation

The English texts are listed on the left and you can enter the translation on the right. The translation can be entered by clicking on the cell and typing in the text. The translation can be saved (to the file specified by the command that started the wizard) by clicking on the SAVE button. You can navigate to the previous screen by clicking on the PREVIOUS button. Note that if a translation for a code has already been set, it will appear for every instance of the code.

You can use ERES_Language.xml (or the copy you modified) in ERES Organizer by adding the -file and -enc arguments (e.g. -file:ERES_Language.xml and -enc:UTF-8) to the java web start (jnlp) file that starts Organizer (in ERESOrganizer.jnlp).

For the web application, edit index.jsp page as follows:

  • Add an import for the LanguageEncoder class:

    <%@page language="java" import="quadbase.common.util.internal.LanguageEncoder" errorPage = "MenuError.jsp" contentType="text/html; charset=UTF-8" %>
    <jsp:useBean id="index" scope="session" class="quadbase.auth.bean.Index" />
    <jsp:setProperty name="index" property="*"/>
                    
  • Add a few lines near the beginning of the jsp to load the language file.

    <%
         quadbase.common.util.internal.LanguageEncoder.load("<language file>", "<encoding>");
         index.setRequest(request, application);
    %>
                    

    where <language file> is the language file (for example, Chinese.xml) and <encoding> is the encoding (for example, Big5).

9.1.2.1.1. Upgrading Language File

When the user upgrades to a newer version, the ERES_Language.xml file needs to be upgraded as well. The language upgrade program will copy over the translations from the previously customized ERES_Language.xml file and append the additional entries in the new version. To use the language upgrade program, navigate to the ERES directory from a console window and use the following command.

java -classpath ".;.\WEB-INF\lib\ERESServer.jar" quadbase.internationalization.UpgradeLanguageXMLFile -from:oldfile -to:newfile -enc:encoding
          

It may be necessary to replace the semicolon with colon and backslash with slash on non-Window environments.

Oldfile refers to the customized ERES_Language.xml from a previous version of ERES, newfile refers to the ERES_Language.xml included in the upgraded ERES installation, and the enc is the language encoding used in the translation. After running the program, the resulting file will be named ERES_Language.xml and you can open it with Translate Wizard to further translate any new entries.

9.1.2.2. Displaying Foreign Characters

Foreign characters can easily be displayed in Designer and the various Viewers. To display foreign characters in a report/chart, you will need to have fonts for that language present on the system. Then, in the report/chart, you can set the font for the object that contains foreign characters to the appropriate system font.

The other option is to modify the font.properties file in the JVM so that foreign characters are supported in the default JVM fonts. For Sun JVMs, the font.properties file is located under the jre/lib directory. The different language files have names like font.properties.ru for Russian, font.properties.zh for Chinese, etc. To change the language settings for the JVM, rename the current font.properties file to back it up, and change the name of the desired language file to font.properties. With the language settings changed in the JVM, the default fonts in ERES (Dialog, Serif, Monospaced, etc.) will display with foreign characters.

9.1.2.3. Entering Foreign Characters

In order to enter foreign characters into any of the ERES interfaces (for example, Organizer and Designer), the following changes to the system settings are required:

  • The default locale of your system must be set to the region for the language you would like to use.

  • The input locale for the system must also be set to the region for the language you would like to use

Note that for Windows the settings can be accessed through Regional Options in the Control Panel.

In addition, the font settings in the JVM must be adjusted to the desired language following the instructions discussed in Section 9.1.2.2 - Displaying Foreign Characters.

Once these settings have been applied, foreign characters can be entered in labels, queries, formulas, and parameters in reports/charts.

9.1.2.4. XML Encoding

By default, ERES uses the UTF-8 character set for encoding when writing to XML. This includes the data registry files, XML report templates, the XML exports, as well as the XML representations of global format information and font mapping. Please note that for most of users it is not necessary to change character set encoding, because UTF-8 fully supports all languages.

This encoding can be changed for other languages by adding a run-time parameter to Organizer and ERES Server. For Organizer, you can do this by modifying the ERESOrganizer.bat/sh file, or modifying the JSP source of the applet page used to launch the Organizer.

To change the XML encoding, add the following argument to the <ERESInstallDir>\ERESOrganizer.bat or .sh file: -xmlEncoding:Encoding. For example -xmlEncoding:ISO-2022-JP would set the encoding for the Japanese character set.

If you are running Organizer through an applet, you will need to add the following parameter to the applet JSP page: <PARAM NAME="xml_encoding" VALUE="ISO-2022-JP">.

This parameter also needs to be set for the server. For more information about server settings, please see Section 1.4.1.3.1 - Secured Parameter.

9.1.2.5. Exporting With Foreign Characters

Most of the ERES export formats will be automatically generated with the UTF-8 character encoding. In order to view the exported reports/charts, the client will need to have the appropriate system fonts installed. The only exception to this is the PDF export. PDF format does not depend on client fonts for viewing. Therefore, foreign language fonts will need to be embedded into the PDF document in order for characters to display properly. To do this, you will need to use the PDF Font Mapping feature. Font Mapping can be set in Designer and in API.

If you wish to export the report/chart to a locale different from the one that is set on the machine, you can specify a different encoding before doing the export. This is done using the following method in QbReport:

public void setExportEncoding(String encoding);
        

where encoding is a character encoding supported by the Java 2 platform. For example, the character encoding for English (Windows Latin-1) is Cp1252. Please note that you have to use the canonical name used by the java.io and java.lang APIs.

You can also specify the character set used in the DHTML exports, using the following method in QbReport:

public void setHTMLCharSet(String charset);
        

where charset is a valid character set. For example, a character set for English, used in DHTML documents, is UTF-8.

Full Source Code

Exported Results

9.1.2.6. Specifying Encoding for Text Data Files

By default, ERES uses the system encoding for any text data files. The encoding for input text data files can be set via the API by using the following block of code:

report.getInputData().setDataFile("sample.dat", false, "ASCII");
        

Full Source Code

Exported Results

The above block uses the following method found in quadbase.reportdesigner.util.IInputData:

public void setDataFile(String fileName, boolean isDataSorted, String encoding);