Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Excerpt

July 13, 2006
Submitted by Mike D'Amour, Pentaho Team Developer

With our next GA release coming up, I thought it would be good to get some internationalization expertise into the hands of the community.

...

  1. Unzip the PCI demo to a working locaton on your computer.
  2. Start the PCI demo by executing the start-pentaho.bat|.sh file in the root directory of the demo. If you have any trouble with this, such as conflicting ports or JBoss conflicts, see the Quick Start Guide to help you through. This step will also startup the sample HSQLDB database, which contains the data that we will be using in this article.  
  3. Unzip the Report Design Wizard to a working location on your computer.
  4. Start the Report Design Wizard by executing the reportwizard.bat|.sh file in the root directory of the Design Wizard install.
  5. Wizard Step 1: Name your report, give it a description and choose the <BLANK> template as your starting point.
  6. Wizard Step 2: Using a JNDI connection to the SampleData database, enter the following query into the Query Details box:
    Code Block
    
    SELECT * FROM QUADRANT_ACTUALS ORDER BY REGION
    
  7. Choose Preview. You should see a report that looks similar to the image displayed here.

Image Added

That is all we are going to do with this report in the Wizard. Since we want to demonstrate localization, we do not need to tweak the report features.

...

  • localized_report.xml - this is the report definition in XML format
  • localized_report.properties - this is the default resource bundle for the report
  • localized_report.xaction - this is the action sequence for the report, that tells the server how to run the report.

The first file we care about is the localized_report.xml. We need to change some of the XML so that the report engine knows what strings to look for in our resource bundle instead of directly in the report. We do this by finding any label elements in the XML and changing them to resource-label elements.  This changes how the report engine interprets the text in the label (now resource-label) nodes. It now reads that text to be a key in a resource bundle. The report engine will use that key to find the REAL value to use in the report. Let's change one label, and you can see localization in action:

  1. Open the localized_report.xml file in your favorite text editor.
  2. Search for the word label. The first one you find should look like this:
    Code Block
    
    <label color="#000000" fontname="SansSerif" fontsize="12" fontstyle="bold" height="18" vertical-alignment="middle" alignment="left" width="16%" x="0%" y="0">REGION</label>
    
  3. Change the label element to resource-label, and add the attribute resource-base="". The line should now look like:
    Code Block
    
    <{color:#ff0000}resource-label resource-base=""

...

  1. &nbsp;...{color} width="16%" x="0%" y="0">REGION</{color:#ff0000}resource-label{color}>
    
  2. Note that the resource-base attribute will allow you to specify a resource bundle in a different location, but for our purposes, the resource bundle is in the same directory, so specifying it with an empty string is sufficent. 
  3. ALSO NOTE that if you are using Pentaho Reports (the JFreeReport library) standalone OUTSIDE of the Pentaho platform, the resource-base CANNOT be an empty string. A small misalignment in the code that is logged to be fixed.  
  4. Save, but do not close, the localized_report.xml.

...

  1. Open the localized_report.properties file.
  2. Add the following line in the file:
    Code Block
    
    REGION=Company Regions
    
  3. Save, but do not close, the file.

...

  1. Make sure that your PCI demo server is running.
  2. In your favorite browser, navigate to the PCI demo home page - usually this is http://localhost:8080/pentaho.&nbsp;
  3. Under the Refresh options, choose the Solution Repository, and click OK to confirm you want to refresh it. This step is how we tell the platform to pick up changes to the solution files.
  4. Navigate to Reporting Samples, and find your new report.
  5. Click on the link to your new report, and notice that the column label that used to be REGION is now Company Region. The label for that column was read from your resource bundle as a result of our changes. If you only see a dash (minus) where you should see Company Regions, then go back and check your xml for typos, and make sure that the name REGION you used for the key in your .properties file EXACTLY matches the text in your new resource-label node.

Image Added

Hopefully, by now, you get the jist of how this works. The final step in localizing the report to German is to create the German resource bundle.

...

That's all there is to it! I had you leave your files open, so that you can go back and change the rest of the labels to resource-labels, and move the resources to the English and German resource bundles, to complete the exercise. When completed, your report should resemble the following screenshot:

Image Added

In case you run into any problems, I have included the solution files for this exercise here.