aspose file tools*
The moose likes JSP and the fly likes Disaplying error messages in the different languages. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Disaplying error messages in the different languages." Watch "Disaplying error messages in the different languages." New topic
Author

Disaplying error messages in the different languages.

Milind V. Kulkarni
Greenhorn

Joined: Apr 12, 2002
Posts: 17
Hi All,
Our application requirement is that we have to display the error messages either in English or in German language depending upon the language selected by the user. In our application error is displayed using an Alert mechanism. We are performing some basic validations at the front end and rest of the validations are performed in the middle layer. All the errors that are trapped in the middle layer are propogated back to the Servlet and finally to JSP so that error can be displayed to the user. To handle various attributes of an error we have defined an error object.
To avoid duplicate error messages we are using error codes to display the error messages. Our strategy to display error messages in English or German language is as follows:
1. We have defined the error codes are java script variables in two java script files Error_en_us.js and Error_de_ch.js.
2. Based on the language selection we are loading one of this file for a given session.
3. Depending upon the error code we are retrieving the error message from one of these files.

I am not very sure whether this is the best strategy to handle multi lingual error messages. Any comments on my strategy would be highly appreciated.

Regards,
Milind
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

You might be able to check out Java Internationalization by O'Reilly.
They have a Chapter on Internationalized Web Application -- it might be able to give you some good pointers.
Why are you going to use JavaScript? Why not just use pure Java? What if they have JavaScript disabled in their browser? -- Once you find out what Locale the user wants -- you can store the information in Session and access it that way.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Alternatively, check out the JSP Standard Tag Library that contains some i18n tags.
Simon
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Disaplying error messages in the different languages.
 
Similar Threads
J2EE & EJB roles in Ireland
Displaying English language content in other languages
multilingual in struts
Issue in localising client side javasctip validation error messages of "LiveValidation" in Seam
Finding a language setting or locale of the keyboard