There are lot of articles around that explains i18n. Here is my list of learnings.Our Project dealt with internationalizing the web application to display English and French. Since the 1st version of the application was in production and heavily used by the users, the changes had to be done without much changes in the look and feel of the application.
1. The web application was done using Struts and struts provide resource bundles to accomplish i18n. So no at no extra code written, the application could read the locale specific property files based on the language id of the user.
2. If there is a forecast to internationalize the application then avoid using any values in file constants like default values “Select City”. If the application has to be internationalized this needs to be moved to resource bundle files. No comparisons should be done with the constant values. Needless to say no HardCodings.
3. If the translations are received from any external source, make sure that the current alignment does not get affected so it would be good idea to verify the maxlength of the translated content that would be supported without disturbing the alignment. This can greatly reduce the GUI look and feel issues.
4. When taking care of the special characters in languages like french make sure you have decided upon the encoding to be used. In most cases UTF-8 supports all the special characters. So the ground rule would be to read the characters in the same encoding format as the sender sends it. Lets consider the french data (containing special accented characters) to be displayed from DB to the browser.
a. In the DB the data is stored with Unicode characters like “d\u00e9” for dé
b. When the data is retrieved from DB and added to the formBean, add request.setCharacterEncoding(“UTF-8”) in the reset method. Or instead of adding in all the form beans, use a filter that gets invoked for all the action classes.
c. For JSPs use the page directive <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> to support characters in UTF-8.
5. If the dataStream is read using InputStreamReader use new InputStreamReader(urlInputStream, “UTF-8”). This is assuming the response is being returned as content-type: charset – UTF-8.
With the above taken care, we can try to avoid those irritating square blocks being displayed for french special characters.