Details
Description
I noticed the strong support for different locales by struts, which I
like very much. There is however one thing I am missing. Imagine that my
preferred language as set in the "Accept-language" setting of my browser
(and HTTP header in requests) is: "fr,de" (French and German
respectively). If I go to a Struts site that supports only English and
German (en,de), there is no match at all, no matter that I accept
German. Reason is the following lines in RequestUtils.java:
if (userLocale == null)
{ // Returns Locale based on Accept-Language header or the server default userLocale = request.getLocale(); }So, only the (first) preferred language is considered, and any
successive languages are discarded. According to the HTTP specs, it can
be a list of languages ("nl,en;q=0.8,de;q=0.5,..."). This is why the
HttpServletRequest also has a method getLocales() which returns an
Enumeration. I would like it if Struts would try to match any of the
successive languages for which .properties files exist if the first
isn't matched. I realize that it may cause a performance penalty, so
maybe it can be made a configuration option
(match-second-languages=true/false or something).
I hope you will consider to add this feature.