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

consider second languages in accept-language header

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.2.4
    • 1.4.x
    • Core
    • None
    • Operating System: Linux
      Platform: All
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            jeroen.kransen@ordina.nl Jeroen Kransen

            Dates

              Created:
              Updated:

              Slack

                Issue deployment