Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

On The Fly Internationalization

Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some servlet generated pages and I want them to display in 3-4 more international languages like French, Spanish etc. The problem is the usual technique of using resource bundles can not be used in my case. So I am looking for any ideas on the "On The Fly Internationalization" of the pages. I have visited a site :
This provides the "On The Fly Internationalization". I am open to any ideas in PERL/PHP/Java.
chanoch wiggers
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, as long as you are sure that you are allowed to do this:
URL url = new URL("http://automatic_translation-service");
HttpURLConnection myConn = new HttpURLConnection(url);
/* set the connection to send and receive info */
/* i assume its a post request */
/* set whatever parameters are needed */
String parameters = "lang=" + lang + "content=" + content";
byte[] bytes = parameters.getBytes();
String contentLength = String.valueOf(bytes.length);
myConn.setRequestProperty("Content-length", contentLength);
/* write out the parameters
OutputStream out = con.getOutputStream();
/* Read the output of the translation */
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
while (true) {
String line = in.readLine();
if (line == null) break;
This is probably not the wya I would have gone about it though - automatic translation is good but not good enough to provide reliable and readable quality reading. Why dont you instead get the locale from the servlet context and then user maybe getResourceAsStream() for the resource you require - that will be a much better use of resources on your server since I assume that you content is reasonably static?
String lang = request.getLocale().getLanguage();
if(lang.equals("en") {
} else if {
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this helps...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic