You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lixin Chu <li...@gmail.com> on 2006/08/04 06:56:21 UTC

can not enable I18N properties

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.

Re: can not enable I18N properties

Posted by Lixin Chu <li...@gmail.com>.
I tried Appfuse on my machine, it works. so I assume the browser
configuration is fine.

I use Tiles, Struts, and Spring framework in my application btw.