ktrinad Posted August 20, 2006 Share Posted August 20, 2006 By: Bhavesh Devashrayee - bhavesh5 Internationalization in Jasper 2004-08-13 01:30Can anybody know how to implements concept internationalization in jasper report ? Even if you have clue regarding same do answer ? By: Mykel Alvis - evilarchitect RE: Internationalization in Jasper 2004-08-13 07:06I do something like this now. In my struts app, I pass in the MessageResources as a parameter to the report and the scriptlet saves it in the initialization. On the report, all the static text fields are actually regular text fields that read resources from the MessageResources using a call to the scriptlet. As far as the actual data printed, there's very little you can do. Values are generally represented in a database as currency in a local exchange, so that's pretty static. If you wanted to change that, you'd need to do a scriplet that took the value and an exchange rate, performed the calculation and wrote the output using a formatter. That's my next step to take. By: John Armstrong - siberian1967 RE: Internationalization in Jasper 2004-08-13 07:11I create a Hashtable of formatted message resources like this : Object[] errormessageargs = {}; Hashtable messages = new Hashtable(); mf = new MessageFormat(rb.getString("report.header.project" )); messages.put("PROJECTHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.user" )); messages.put("USERHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.printer" )); messages.put("PRINTERHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.printtime" )); messages.put("PRINTTIMEHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.documenttitle" )); messages.put("DOCUMENTTITLEHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.type" )); messages.put("TYPEHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.pages" )); messages.put("PAGESHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.pagecost" )); messages.put("PAGECOSTHEADER",mf.format(errormessageargs)); mf = new MessageFormat(rb.getString("report.header.totalcost" )); Then I accept them into my report like this: <!-- Localized messages --> <parameter name="messages" class="java.util.Hashtable"/> Then I access them like this <textField> <reportElement positionType="FixRelativeToBottom" x="1" y="20" width="136" height="15"> </reportElement> <textElement> <font fontName="Arial" size="10" isBold="false"/> </textElement> <textFieldExpression><![CDATA[(String)($P{messages}).get("REPORTINGTITLE")]]></textFieldExpression> </textField> This allows me to provide I18N strings, currencies and dates since they are being formatted in my servlet which has proper access to the browsers Locale object. This for me is being done in a struts Action and I am using the JRBeanCollectionDataSource based reporting stuff, it works great for us! By: John Armstrong - siberian1967 RE: Internationalization in Jasper 2004-08-13 07:12Note: by the time any data gets into the Hashtable its been cast to a String to make life easier in the Jasper Report. So if I have a formatted currency I get it into a string before I add it in. This is all just for display so this concept works fine. Link to comment Share on other sites More sharing options...
avinashp Posted May 16, 2012 Share Posted May 16, 2012 I want to print some unicode character(of Hindi language) as output.For that i set following test element for field "name" in my .jrxml file <textElement> <font fontName="Mangal" size="12" isBold="true" isUnderline="false" pdfFontName="mangal.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/></textElement><textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>I have set pdfFontName as mangal.ttf ,and i am passing the unicode value (for hindi name) from my java code.Even I save my java code in UTF-8 formate and compile it with the UTF-8 encoding in eclipse IDE. Still that hindi word didnot not disply.Plz give me some short example how can i display hindi word providing its unicode dynamicaly into my jasper report.Which setting i want to apply to display the field in hindi?Thank you in advance... Post Edited by avinashp at 05/16/2012 14:50Post Edited by avinashp at 05/16/2012 15:17 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