Title: How to test only for the language-code but not for the country?
Tanks for your answer. Do you hava an idea how i could pack this in a Tag? Or even better if there allready exists a Tag in struts that allows to include a HTML-text only if a certain language is chosen?
 
Beat Friedli

------------------------------------------------------------------------------

 
i faced a similar problem and i override the processLocale method of ActionServlet as follows...
 
 protected void processLocale(HttpServletRequest request) {
 
  // Validate that we need to create a Locale
  if (!locale)
   return;             // Service not requested
  HttpSession session = request.getSession();
  if (session.getAttribute(Action.LOCALE_KEY) != null)
   return;             // Locale object is already present
 
  // Use the Locale returned by the servlet container (if any)
  Locale locale = request.getLocale();
  if (locale != null)
  {
   if (locale.getLanguage().equals("en"))
    locale = new Locale("en","US");
 
   if (locale.getLanguage().equals("nl"))
    locale = new Locale("nl","NL");
 
   if (!(locale.getLanguage().equals("en") || locale.getLanguage().equals("nl")))
    locale = new Locale("nl","NL");
    
   session.setAttribute(Action.LOCALE_KEY, locale);
  }
  else
  {
   locale = new Locale("nl","NL");
   session.setAttribute(Action.LOCALE_KEY, locale);
  }   
}
 

 

I want to test the Accept-Language and show a french message if the user speaks french.

But the following code doesn't take care of the Accept-Language fr-ch.

<logic:equal value="fr" header="Accept-Language">
  Welcome french
</logic:equal>

And this code doesn't take care of the Accept-Language fr-ch.

<logic:equal value="fr-ch" header="Accept-Language">
  Welcome french
</logic:equal>

Do I have to write my own tag? Has anybody allready an apropriate tag?

thanks

Beat Friedli



Reply via email to