i-net Clear Reports

Multi Language Reports Readme

This sample demonstrates the usage of multi-language reports, i.e., reports with labels displayed in the language (locale) being used on the client computer requesting the report. It contains the following files:

  1. multi-language-reports.readme - this readMe
  2. Engine_setLocale.java - This sample demonstrates how to set the Locale while exporting a report into a .pdf file.
  3. setLocale_sampleReport.rpt - The report being used in this sample. It contains text objects only.
  4. SetLocale_Sample*.java - The Java source code of the ListResourceBundles
  5. SetLocale_Sample*.properties - The property files of the PropertyResourceBundles

How to use these samples?

  1. Compile the file SetLocaleToEngine.java if you would like to use the export sample.
  2. Set the base file (.class or .properties) of the RessourceBundle in the property “Language Resource” (see: i-net Clear Reports configuration), e.g.:
    LanguageResource=samples.multi_language_reports.SetLocaleSample
  3. Compile the files SetLocaleSample*.java if you like to use the .class files as ListResourceBundles. If you like to use the .properties files as PropertyResourceBundles then you don't need to compile the .class files.
  4. Execute the file SetLocaleToEngine.class:
    java -classpath .:core/ClearReports.jar;. samples.multi_language_reports.SetLocaleToEngine

    or start the i-net Clear Reports server as a Java application or a servlet.

  5. Provided you started i-net Clear Reports as an application or servlet you can now request the report “setLocale_sampleReport.rpt” from a client with English, French or German locale settings and you will see the labels of the report in the specified language. The report engine i-net Clear Reports reads the used client locale from the HTTP Header of the report request. It is also possible to set the locale in the report URL (…&locale=de) or with the method Engine.setLocale. The sample file “SetLocaleToEngine.java” shows how to do it.

Character Encoding

From the API documentation of java.utils.Properties:

“When saving properties to a stream or loading them from a stream, the ISO 8859-1 character encoding is used. For characters that cannot be directly represented in this encoding, Unicode escapes are used; however, only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.”

If you have property files saved in Unicode or UTF-8 encoding then you can use the native2ascii tool which is part of the JDK to convert your property files, e.g.:

  • Unicode property file:C:\java\bin\native2ascii.exe -encoding UTF-16 SetLocaleSample_xx.properties SetLocaleSample_xx2.properties
  • UTF-8 property file:C:\java\bin\native2ascii.exe -encoding UTF-8 SetLocaleSample_xx.properties SetLocaleSample_xx2.properties

i-net software strives to provide accurate product documentation. Please give us your feedback using the form below.
NOTE: This form is for documentation feedback only. For technical assistance, please send an email to clearreports@inetsoftware.de.

 

© Copyright 1996 - 2012, i-net software; All Rights Reserved.