I18n Best practices for web application- Part 1
By Mahipalsinh Rana on Jun 09, 2008
I have created clear and concise best practices list for making your application I18n'ed.
- No hardcoded strings
- Data format I18n
- Number format I18n
- Usage of Apostrophe in Message Format class.
- Currency I18n
- Sort I18n
- Calendar I18n
- Read/write file in UTF-8
- Use methods like :public OutputStreamWriter(OutputStream out, String charsetName); public InputStreamReader(InputStream in, String charsetName)
- Locale lookup should be correct - Find out what lookup mechanism needs to be used.
- Send/Receive Locale when communicating with other compoments
- If any property in property file does not need to be locaized put a comment on top property file.
- Make sure property file does not have duplicate properties
- When you use Message format to parse string make sure "'"(aphostrophy) in string is escaped.
- File system name should be allowed to i18n
- Encoding of file should be "UTF-8"
- <%@ page contentType="mimeType ;charset=characterSet ?" | "text/html; charset=UTF-8" %>
- Use JSTL taglib to include the messages in the JSP file.
- Request and Response should be in "UTF-8"
- Should not use duplicate key properties file
- Try to create less number of Property files
- Try to use same message which already found in other components or even products if it make sense.
- Do not change layout of message once translated
- Property file for UI message and Log message should be SEPARATE
- Message should not be slang or culturally sensitive
- Always create _en.properties file along with base property file
- Each button/textfield should have enough space to accommodate localized sentences
- Layout and Text rendering
- Input validation should consider multibyte data
- If you are writing a WEB UI, the UI should appear in the client locale, not the server locale. Logging should be done in the server locale to avoid log messages with mixed data from different locales. Use UTF-8 as encoding for the web UI, because UTF-8 supports all languages.
- Reading and writing data to/from database should be in UTF-8
- Make sure all your Junit Testcase is I18n'ed. This will help in great way to integrate i18n testing in Unit testing.
Refer AJAX I18n
- Java I18n Code samples
- Java EE Project I18n and L10n
- Developing Multilingual Web Applications Using JavaServer Pages Technology
- Sun Product I18n Taxonomy