How to make my java bean internationalization?
hi,
I have a project on tomcat. I have rewrite my jsp to multi-language according to user's browse language setting. User's language is English, the jsp shows them English. User's language is Chinese, the jsp shows them Chinese, and so on. But in my java bean code, some exception are thrown out with some message or alert. Can anybody tell me how to make these java beans show the language string acording to user's browse language setting?
thx
Pierre
I am not sure that I interpret the question correctly, but since you say that
"some exception are thrown out with some message or alert" I am guessing that these are exceptions you are simply catching?
Here's a good explanation of how to create your own localized messages for such hardcoded exceptions:
http://www.ifi.uio.no/dok/java/tutorial/i18n/exception/hardcode.html
Dear one_dane,
Thank you. That is a great document to me. The fact is that my owner code throws exception with a string. The code is:
if(amount<0) throw new Exception("Please input correct amount.");
If the code is in jsp, I can convert it to a internationalized String using struts tag <bean:message...>. But it is in a deep function of java class. So must I add a Locale object parameter to the function and all calling functions?
thx
yours,
Pierre