1 Reply Latest reply on Apr 9, 2010 9:07 AM by 843810

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

      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 ?
        • 1. Re: Externalizing the string messages in .js files to Java property files

          In your case, moving strings now to properties files might require lot of code change.

          One suggestion from me is,
          - to externalize the hardcoded strings to a separate .js file.
          - Define a directory structure to organize English and other localized .js files in your application
          - Develop a mechanism to dynamically load localized .js files and fetch localized strings for use in your application based on user's preferred language
          NOTE: Translated .js files should be UTF-8 encoded, unless your application supports any other native encodings.

          This also requires code change, but might require lesser effort.
          Hope it helps.

          My 2 cents.