HOME > SUPPORT > LOCALIZATION

Localization

Overview
Multi-template Approach
Language String Substitution Approach


  Overview

There are several possible solutions for generating reports in different languages. Below, we discuss (1) creating a separate template for each additional supported language and (2) using language keys in place of static text for labels in a template.

Multi-template Approach

Perhaps the most straight-forward approach is to design the master set of templates in the predominant language, then duplicate the set of templates for each additional language that the application needs to support. Then templates can be loaded from their language package as simply as loading the original template:

// Construct template resource path
String path = getTemplateName() + "_" + getLanguage() + ".rpt";

// Load template from res path, eg.: "/wherever/Sales_French.rpt"
RMDocument template = new RMDocument(path);

// Generate report normally ...
RMDocument report = template.generateReport(dataset);

This approach has several advantages. First, the task of localization can easily be separated from the development chain, so language support can be added or modified without having to rebuild the main application. Second, the process of translation can be done by non-developers simply by translating the static template text using the RMStudio page layout application. Third, it is possible to perform more flexible translation, like increasing the size of columns or fields, and re-ordering or adding/removing fields.

Language String Substitution

Another possible approach is to replace static text found in the template with simple language keys. So instead of using the static text "Regional Sales Report", the template author would instead type the string "@ReportTitleLabel@". Then when the template is used to generate a report, an additional Map can be used to provide the language specific string for that label.

// Load template from path
RMDocument template = new RMDocument("/Templates/Sales.rpt");

// Create language map
Map languageMap = new HashMap();
languageMap.put("ReportTitleLabel", "Regional Sales Report");
languageMap.put("DateLabel", "Date");

// Generate report with dataset and language map (as "user info")
RMDocument report = template.generateReport(dataset, languageMap);

This approach is particularly handy if your application already has support for mapping language strings.