简体   繁体   中英

Change a web application language

I have a web application built in a single language and I would like to internationalize it by adding a few more languages. I would like to do it using a properties file containing keys and values (keys like 'name' and the value of this key changes in each properties file) . I read some time ago that there were an application that was capable of extract the labels from the jsp files and generate the properties file which the keys. Can someone tell me what would the best way to do this?

Thank you.

Try using ResourceBundle. Say you have your localized property files called Resources_EN.properties, Resources_FR.properties, etc. You have to put your property files in the classpath. To get a localized string you do the following:

ResourceBundle resourceBundle = ResourceBundle.getBundle("Resources", new Locale("EN");
String value = resourceBundle.getString("myKey");

Is that web application used Struts? If yes. It very easy to change the code. You have to change the Web.xml for I18N and jsps to get the property file according to language.

step 1 : use properties file for every language you want
step 2 : in all your view pages dont give static values but pick from language properties file

you can also refer this link as per your comfort

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM