JSTL I18N Overview
July 27, 2010 16:42:08 Last update: July 30, 2010 18:39:48
Three key concepts are associated with internationalization (I18N):
When a user request comes to a web application, the resource bundle is retrieved using the basename and the preferred locales. The preferred locale can be either application-based or browser-based. When the locale is set by the application, it takes precedence over browser based locale setting.
Given an ordered set of preferred locales, the resource bundle is searched in this order for each locale in turn:
A fallback locale may be defined for JSTL. If no resource bundle is found with the above algorithm, the fallback resource bundle is used.
- Locale: a locale is identified by a language code along with an optional country code. For example:
enfor English,en_USfor US English,zh_CNfor simplified Chinese. - Resource Bundle: a resource bundle is a properties file localized for a specific locale. For example,
messages_en.propertiesmay be a resource bundle for English,messages_zh.propertiesmay be a resource bundle for Chinese. - Basename: a basename identifies the same set of messages represented by all related resource bundles. In the above example, the basename is
messages.
When a user request comes to a web application, the resource bundle is retrieved using the basename and the preferred locales. The preferred locale can be either application-based or browser-based. When the locale is set by the application, it takes precedence over browser based locale setting.
Given an ordered set of preferred locales, the resource bundle is searched in this order for each locale in turn:
- basename_language_country_variant
- basename_language_country
- basename_language
A fallback locale may be defined for JSTL. If no resource bundle is found with the above algorithm, the fallback resource bundle is used.
- Language code: http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt
- Country code: http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html