Hi,
I am trying to enable I18N in my struts based application, here is what I
have done:
- added a LocaleFilter, which I copied from Appfuse:
String locale = request.getParameter(locale);
Locale preferredLocale = (*null* == locale) ? *null* : *new*Locale(locale);
HttpSession session = request.getSession(*false*);
* if* (session != *null*) {
* if* (preferredLocale == *null*) {
preferredLocale = (Locale) session.getAttribute(Globals.*LOCALE_KEY
*);
} *else* {
session.setAttribute(Globals.*LOCALE_KEY*, preferredLocale);
Config.*set*(session, Config.*FMT_LOCALE*, preferredLocale);
}
* if* (preferredLocale != *null* !(request
*instanceof*LocaleRequestWrapper)) {
request = *new* LocaleRequestWrapper(request, preferredLocale);
LocaleContextHolder.*setLocale*(preferredLocale);
}
}
chain.doFilter(request, response);
// Reset thread-bound LocaleContext.
LocaleContextHolder.*setLocaleContext*(*null*);
- created ApplicationResources_XXX.properties
- added message-resources parameter=ApplicationResources / in
struts-config.xml
- added %@ page language=java pageEncoding=UTF-8
contentType=text/html;charset=UTF-8
%
in each JSP file
- in my IE, I also added additional languages.
but i only saw english strings. no effect whethere I have html:html
locale=true/ or not.
anything else I miss out ?
thanks
lixin
ps. i debug the filter, it seems that the language is indeed saved in the
session though.