Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Externalizing the string messages in .js files to Java property files

 
Brian Fed
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a software maintanenace project consisting of a large enterprise java/j2ee based web application. We need to introduce Internationalization(i18n) support to this web application. This j2ee based web application uses technologies like java, oracle database, jsp, javascript, websphere v6.1 application server struts, web services, spring, xml, jms, ejb etc and this web application is mostly (oracle) database driven.

To this web application, we have to add internationalization(i18n) support for languages ike Spanish, French and later extend to other languages.

We have lot (around 50) javascripts files (.js) that are used by jsp files. Lot of string messages are hard coded in the .js files and we need to externalize these string messages to java property files and my question is how do we do that ? without impacting the application functionality. how do we externalize the hard coded string messages in .js files to java property files ? what is the optimal solution for my scenario which can reduce our development time in the process of refactoring the huge code base ?

Can you pleaes clarify ?
 
Maximus Moothiringus
Ranch Hand
Posts: 46
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm... I dont know about JavaScript and internationalization..

We have a discussion in the JSP forum about almost the same thing. I am sure since you are using Java/J2EE, you might be able to make use of that. Just a suggestion that you take a look at that.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a build process generate the files or have some process that will generate the js files and cache it.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65113
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The server-side properties files are not available to the client, obviously. So as has been indicated, you'll need to do something on the server to create client-side resources that you can use. It can be a build-time solution, as Eric suggested, or can be an execution time, JSP-initiated solution.

In either case you'll need to take the information for the various locales and put them into JavaScript constructs. Be sure to only send the information for the user's locale (available from the request headers) -- no sense sending all the locales.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic