nikunj321 Posted May 22, 2009 Share Posted May 22, 2009 I have a report which is running properly.Can anyone please help me how to use REPORT_RESOURCE_BUNDLE parameter to print the same report in Spanish lang and English at any point of time? Link to comment Share on other sites More sharing options...
ddavis539 Posted May 22, 2009 Share Posted May 22, 2009 You just need to create a java properties file and place it in a resource directory, for example projectStaticText.properties. We put our fonts and properties files in a single resource directory which is added to the iReport classpath. In version 3.5.x this is done by going into the tools-->options menu, choosing classpath, clicking on add folder and choosing the resource directory. If fonts are in that directory, you can choose the FontPath tab and click on the chekcbox to include that directory for fonts. In the file you need to add label/header terms to be translated (ie name=Name). Modify the iReport Resource bundle property and set it to 'projectStaticText'. You can then create Text fields in the report and reference your properties using the $R{} syntax ( $R{name} ). To create a Spanish version, you need to create a 2nd file in the same directory called projectStaticText_es.properties. Use the same property tags in this file, but put in Spanish terms (name=Nombre). To see the report in Spanish from iReport (version 3.5), you need to go into tools-->Options menu, select the Compilation and execution tab and change the Report Locale to Spanish and press ok. When you press preview, it should pull in the Spanish tags. If you're going to use extended ascii or Unicode characters, we've found it's much easier to store them in properties files as Javascript escape characters. Español would be Espa\u00F1ol. There's a nice website that makes it easy to produce the Javascript escapes: http://rishida.net/scripts/uniview/conversion.php One thing to keep in mind is the font you're using needs to have scripts for all of the characters you intend to display across all languages. This usually isn't a problem with European languages, but can be an issue when you want to switch between English and Asian languages. We usually use Arial Unicode or Bitsream cyberbit, with pdf embedding and using the Unicode-H encoding to create a single multilingual report. Another option is to create different language versions of the report, allowing you to target several different fonts that work in the given language. When generating the reports at runtime with Jasper, we just pass the desired locale string in to the report as 'REPORT_LOCALE' which is a built in parameter for all reports.Post Edited by ddavis539 at 05/22/2009 15:50Post Edited by ddavis539 at 05/22/2009 15:52 Link to comment Share on other sites More sharing options...
nikunj321 Posted May 25, 2009 Author Share Posted May 25, 2009 Thanks for your detailed discussion about how internationalisation works.I needed some more help on this.1.I changed locale execution tab to spanish ,but still it gives the output in default language.Is this only step solve my issue?2.If i want to pass value to REPORT_LOCALE variable(which is in built) for spanish tag,how and what value should i pass? Link to comment Share on other sites More sharing options...
ddavis539 Posted May 26, 2009 Share Posted May 26, 2009 nikunj321Wrote: Thanks for your detailed discussion about how internationalisation works. I needed some more help on this. 1.I changed locale execution tab to spanish ,but still it gives the output in default language.Is this only step solve my issue? 2.If i want to pass value to REPORT_LOCALE variable(which is in built) for spanish tag,how and what value should i pass? Did you create a properties file with Spanish terms in it and convert your report to use Resource string references ($R{Name})? Simply changing the locale won't do anything unless you've created a localized report layout. As needed, your database queries for the report may need to be modified to pull out any database-based localized data as well, based on the report locale. For Spanish you have a choice of simply using the generic locale for Spanish "es" or using country-specific versions (es_MX for Mexico, es_ES for Spain, etc..). You'll use this locale code (two letter language + optional 2 letter country) when naming the properties file and a matching locale should be passed in as a String value for the REPORT_LOCALE parameter. Link to comment Share on other sites More sharing options...
nikunj321 Posted May 26, 2009 Author Share Posted May 26, 2009 I am able to do intenationalisation by creating propeties file for corresponding locale..It is working fine....I have one question..can we create dynamic translation of the resource which we are defining in properties file instead of defining for each language? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now