Home
Analytics
How to set localization text dynamically
bitisony
I want to define some parameters in the properties files, the format is as:
company information = {company name} Inc
I do not find any interface that can be extended to do this requirement.
Would you like to give me some suggestions?
Thank you very much for your help!
Find more posts tagged with
Comments
Virgil Dodson
Hi bitisony,<br />
<br />
If you are talking about using a name/value pair properties file in order to support localization of BIRT report content, then yes, BIRT supports this. Basically, you create your properties file, like MyProperties.properties, and add your name value pairs, like welcomeKey=Hello. Then create a new properties file for each language you want to support, like MyProperties_en_US.properties.<br />
<br />
In the BIRT Designer, click into the white space of the report, select the Resources tab in the Property Editor, and point at your original properties file (without the locale indicator at the end).<br />
<br />
Now that this is set, you can select label elements within the report, and using the Localization tab, assign a key to each label. Localization is also available within the chart builder and parameters.<br />
<br />
There are a couple of places you can get more info on Internationalization wtih BIRT:<br />
<br />
FAQ on BIRT Exchange<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/wiki/BIRT:Internationalization/'>BIRT:Internationalization
- BIRT Wiki - BIRT Exchange</a><br />
<br />
Slides on Internationalization from EclipseCon showing screenshots and how to preview in different locales within BIRT Designer.<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/810-eclipsecon-2009-advanced-birt-report-customization/#description'>EclipseCon
2009 Advanced BIRT Report Customization - Designs & Code - BIRT Exchange</a>
bitisony
Hi Virgil,
I think you do not understand my question clearly.
It is my fault, I do not give you enough details.
Now let me give you more details.
I want to define a customed format in the localization text.
As:
WelcomeKey = Hello {customer name}.
I want to parse the {customer name} into a real name, like "Virgil".
So in the report, it shows "Hello Virgil". not "Hello { customer name}".
What I want to know is that whether there are any interfaces I can use to extend for parse customed localization text.
Virgil Dodson
Hi bitisony,<br />
<br />
There are a couple of different ways to do this. First, you can have various fields in the properties file that you can have appear one after another using the INLINE property. This way, you can get the localized message and then append the company directly after. (see screenshot)<br />
<br />
You can also put curly braces {0} into the properties file and then replace those fields with data at runtime. This way uses JavaScript in a Dynamic Text control like below:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
//set up array to hold constants you want to replace
l10nParams = new Array(1);
//fill first array value with Customer Name
l10nParams[0] = row["CUSTOMERNAME"];
//get welcome message, current locale, and replace curly brace values with array values
reportContext.getMessage("welcomeString", reportContext.getLocale(), l10nParams);
</pre>
<br />
I created a report example with BIRT 2.3.2 (enclosed)