Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2351

consider second languages in accept-language header

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.4
    • Fix Version/s: 1.4.x
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Operating System: Linux
      Platform: All
    • Bugzilla Id:
      33298

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jeroen.kransen@ordina.nl Jeroen Kransen
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: