• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 46
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67754
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
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic