Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get locale

 
Anthony Karta
Ranch Hand
Posts: 342
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to get locale setting from user computer or HTTP header?

what we want to do is format the date and currency based on locale setting in user computer? is it easier we implement in Servlet or JSP?

and next thing is, we would like to display HTML text based on user language, say if someone in Japan browse our website, we show it in Japanese. what we should do to implement this?

many Thanks in advance
Tony
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, please read this.

I did a google search with the words "servlet jsp internationalization" and came up with quite a few good pages. Click here
 
Hussam Bamatraf
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the the language preferred by an HTTP client by parsing the Accept-Language header of HTTP protocol. Example of this header:
Accept-Language: en-US; q=1.0, en;q=0.5
This header indicates that the user prefers American English (quality 1.0) but will take any form of English as an alternative (qualiity 0.5).
You can write a servlet to do internatinalization and direct user to a page according to their langauge preference.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic