pnvswamy Posted April 6, 2009 Share Posted April 6, 2009 Please tell me how to provide I18N for reports in IReport tool.What i done is:<jasperReport name="report3" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="prop_en" whenResourceMissingType="Empty"> And in my text field is like this<textField hyperlinkType="None"> <reportElement x="277" y="0" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$R{name2}]]></textFieldExpression> </textField>----------------------------------------------------------------And my prop_en.properties file is like thisname=codename2=name-------------------------------Then i am getting the comiler error like:Error filling print... Can't find bundle for base name prop_en, locale en_US java.util.MissingResourceException: Can't find bundle for base name prop_en, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1508) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1262) at java.util.ResourceBundle.getBundle(ResourceBundle.java:964) at net.sf.jasperreports.engine.util.JRResourcesUtil.loadResourceBundle(JRResourcesUtil.java:572) at net.sf.jasperreports.engine.util.JRResourcesUtil.loadResourceBundle(JRResourcesUtil.java:510) at net.sf.jasperreports.engine.fill.JRFillDataset.loadResourceBundle(JRFillDataset.java:527) at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:555) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1192) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:843) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:792) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:890) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986) PLease give me help Link to comment Share on other sites More sharing options...
lucianc Posted April 6, 2009 Share Posted April 6, 2009 You need to place the prop_en.properties file on the application classpath. E.g. create a directory, put the file there and inlcude the directory on the classpath.HTH,Lucian Link to comment Share on other sites More sharing options...
C-Box Posted April 7, 2009 Share Posted April 7, 2009 Hi Lucian, just a short question: What is the better way for using i18n: Using the $R{SomeResourceName} or the str() function?I just created a iReport-Plugin to transform a bunch of JRXML to the str() Function. So all static texts (or also phrases in textfieldexpressions/parameters or variables) are automatically transformed into textfields and all phrases get surrounded with str() eg: StaticText with "OrderNo.:" will transformed to Textfield with expression str("OrderNo.") + ":" or TextField with expression "payable within " + $F{days} " after date of invoice ("+$F{paydate} + ")" will be transformed to str("payable within") + " " + $F{days} +" "+str("after date of invoice") + " ("+$F{paydate} + ")" so that I can extract all phrases to our database-dictionary what is the base for my own ResourceBundle that is passed for fill process.But I'm not sure if this is the best way, as there is the $R{} Syntax also!?!?!Will the str() Function be included in future versions also?????tia + regards from summer like Dresden / GermanyC-Box Link to comment Share on other sites More sharing options...
lucianc Posted April 7, 2009 Share Posted April 7, 2009 $R{} and str() are largely the same thing. The functional difference is that $R{} can only be used with fixed/static keys, while str() can be used with dynamic message keys, e.g. str("message.prefix." + $P{message}).So if you have static message keys you can use any of them, I can't recommend one over the other. The fill time performance is the same, $R{} placeholders actually get translated at compile time to str() calls.In the case you describe you might be interested in the msg() built-in method as well. This method leverages java.text.MessageFormat functionality and is generally used when parametrized messages are in place.For instance, you could have payable.within=payable within {0} after date of invoice ({1}) in the resource bundle, and use msg(str("payable.within"), $F{days}, $F{}) in the report.This is generally considered a better way to localize messages than localizing message chunks. The only problem might be to write a utility that processes text field expressions into such parametrized messages.Regards,Lucian Link to comment Share on other sites More sharing options...
C-Box Posted April 8, 2009 Share Posted April 8, 2009 Thx Lucian for your answer. I think the str() Function is more readable within the design for "0815" Customers that want to see what they get in design mode.If I change to msg() Function I would have just a key out of the resource bundle and not the full (human readable) text. My "str() transformer" works pretty well so far with parsing all expression chunks and keeps the design more readable (IMHO).The only bad thing when transforming static texts to textfields is, that there isn't a constructor for JRDesignTextField that gets an JRBaseElement (like JRDesignStaticText) for copying all the base attributes to the new textfield. So I have to use beanutils ... JRDesignTextField tf = new JRDesignTextField(); BeanUtils.copyProperties(tf, staticText);... for that purpose. Perhaps you could add such a feature (or did I something wrong) ?regards from again/still very sunny GermanyC-Box Link to comment Share on other sites More sharing options...
lucianc Posted April 8, 2009 Share Posted April 8, 2009 CBoxWrote: The only bad thing when transforming static texts to textfields is, that there isn't a constructor for JRDesignTextField that gets an JRBaseElement (like JRDesignStaticText) for copying all the base attributes to the new textfield. So I have to use beanutils ... JRDesignTextField tf = new JRDesignTextField(); BeanUtils.copyProperties(tf, staticText); ... for that purpose. Perhaps you could add such a feature (or did I something wrong) ? Indeed, there is no built-in method for achieving this. Please log this as a feature request so that we remember it.Regards,Lucian Link to comment Share on other sites More sharing options...
aymen.bensgaier Posted August 26, 2013 Share Posted August 26, 2013 Hello,i have problem with passing the main report resource bundle ti the subreport !! in the main report the ressource work perfectly ! i made it as a subreport parameter and renamed to not bec confused with the subreport default ressource bundle .and even after that i'm still getting null as value . can someone help pls it's urgent Best regards 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