This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
Just to elaborate a bit, you can put all the text you wish to localize into a properties file, where each line has the format key=value where value is the string to be displayed and key is a unique string that you'll use in your program to refer to the entry. Then have that properties file translated (just the values, not the keys - you need to keep the keys the same so that you can refer to them in your program) into each language you wish to support. The base file names of all the properties files must be the same except for a suffix describing the locale. See java.util.ResourceBundle for details. For example, in a JSP that needs to count from 1 to 3, you need a properties file like this:
and one in French, say
The tricky part is where to put the files. They need to be treated like .class files from the standpoint of the JSP container's class loader. So, for example, you could put them in the web application's /WEB-INF/classes file or a subdirectory from there, if you want to use a package structure:
In the example above, I'm using a subdirectory named "sample". Then in your JSP:
The resource bundle structure works well in that it automatically allows you to distinguish between Swiss French and Canadian French, for example, and that it looks through the hierarchy of resources for default values. ------------------ Phil Hanna Author of : JSP: The Complete Reference Instant JavaServlets
Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>