Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Localization of text, not using locale
hallj05
<p>Hey,</p><p> </p><p>Is there a way to use the localization tool of BIRT for labels and text but make it based off of something other than the locale?</p><p> </p><p>Since currently we are using the locale to do the formatting of numbers/dates/currencies and we have a separate report parameter that we are using for the language. So is there a way to make it use the language report parameter we have created instead of the locale for localization?</p><p> </p><p>Edit: Using a .properties file for the localization.</p><p> </p><p>Edit2: So if we have the following:</p><p>locale: fr_FR</p><p>report parameter lang: en</p><p>properties file: MyResources.properties</p><p> </p><p>we want the properties file MyResources_en.properties instead of MyResources_fr_FR.properties to be used for the localization</p><p> </p><p> </p><p>Edit3: When using the locale to format the numbers/dates/currencies is it possible to make it not do any formatting on certain fields? Since if the above is not possible then I might use the locale for the language and create functions to do the formatting of numbers/dates/currencies, but at the moment they always change to match the formatting of the locale.</p><p> </p><p> </p><p>Thanks for any help!</p>
Find more posts tagged with
Comments
kclark
<p>You can set different labels to different locales using some script like this</p><pre class="_prettyXprint _lang-auto _linenums:0">//label oncreate scriptimportPackage(Packages.java.util);var lc = new Locale("de_DE");this.text = reportContext.getMessage("text1", lc)</pre><p>Depending on how large your report is you could use that same logic for each of your report items. Then based on your report parameter lang change the language using something like this.</p><pre class="_prettyXprint _lang-auto _linenums:0">if(params["parameter lang"] == "DE") { //label oncreate script importPackage(Packages.java.util); var lc = new Locale("de_DE"); this.text = reportContext.getMessage("text1", lc)}else if(....) { ....}</pre><p>It'll take a bit of coding depending on how many items you have but I think this would be the best way to get the results your wanting.</p>
micajblock
<p>Take a look at this DevShare</p><p> </p><p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1078-new-advanced-localization-technique/'>http://developer.actuate.com/community/forum/index.php?/files/file/1078-new-advanced-localization-technique/</a></p>
;
hallj05
<p>So we have decided to use the locale setting to do the localization of the labels, and to use the above approaches to do the formatting like</p><p><span>this</span><span>.</span><span>getStyle</span><span>().</span><span>numberLocale </span><span>=</span><span> </span>
<span>this</span><span>.</span><span>getRowData</span><span>().</span><span>getColumnValue</span><span>(</span><span>"Locale"</span><span>);</span></p><p> </p><p><span>But the issue with this way that I have encountered is how to I change the formatting of numbers that are in charts? Which could be labels in the x/y axis or the hoover text</span> and maybe other areas of the chart. Since when I try to use the getStyle in a chart script it gives errors.</p><p> </p><p>Thanks for all the help!</p>
micajblock
<p>What version of BIRT are you using? OS or commercial?</p>
hallj05
<p>I'm using BIRT 4.2.2, the OS version.</p><p> </p><p>To give more of an overview of what we are trying to do.</p><p>We have a UI that calls BIRT to display reports, which in the UI we have it so that users can set up certain ways of formatting numbers/dates/time fields (as in they can set the thousand separator, decimal symbol, European/American date format) and the user can change the language that the UI is displaying in.</p><p> </p><p>When we click on the link that takes us to the BIRT reports, we are currently passing in the language that the UI was in, which gives us the language part of a locale, but since we have formatting set up where users can specify exactly how things will look it doesn't match any given locale. So we are giving the user the ability to set a locale which will only be used for the formatting on the BIRT reports.</p><p> </p><p>So at the moment we are using the language as the locale and then doing the scripting method of specifying the locale to use on the date/number/time fields, which I think I know how all of them go except for the chart scripts.</p><p> </p><p>Is there a way to tell the reports to list all strings as one locale (language) and to have all number/date/time to use a different locale (formatting) without having to go to each element that needs to use a locale different of the set locale?</p><p> </p><p>Also is there a way to create a custom locale? Since then we could set it up to use the formatting that we have set in our UI.</p><p> </p><p>Thanks for taking time and helping!</p>
micajblock
<p>I am not sure how to do this in charts. I am currently working on a project that is keeping me very busy. Hopefully some else know the answer.</p>