• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing Javascript prompts according to Locale

 
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

In an application, the user selects language in the login page itself, so the interface is loaded in selected language using ResourceBundle. But the Javascript file is consistent, and manually changing seems impossible. The JS prompts messages in English language and I want it to show message in user-selected language. How can I accomplish this? Is there any way, I can do a check before alerting when a particular JS function is called?
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I can take field labels from the page itself For example "comment can not be null". "comment" is field label, it will be translated, but what about "can not be null"?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wouldn't it be easier to have one Javascript file for each language you support, and just have the page download the Javascript version for the language which the user selected?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or better yet, have a JS file for each language that only contains a translation table for the text. That way, no code need be repeated.

(Or use Ajax to load such a table.)
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
For JS, there is only one file, and I can get the language from some class and then display proper prompts after checking the language, because having different JS files, I think will build up the work.
Now I do not know how to call the java method from the JS file, and determine the language. Please help me.

Update: I have specified seperate file name in a JSP thats included with every other JSP, and there I can get the language simply there.

But please explain me this:

Bear wrote: Or better yet, have a JS file for each language that only contains a translation table for the text

 
reply
    Bookmark Topic Watch Topic
  • New Topic