Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15991

Wrong locale used in multilingual wiki

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 9.11.8, 10.10
    • Fix Version/s: 11.2-rc-1
    • Component/s: Localization
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Pull Request Status:
      Pull Request accepted
    • Similar issues:

      Description

      Steps to reproduce

      1. Login as an Admin
      2. Set the wiki as multilingual
      3. Remove the English language and add French instead (both default and supported)
      4. Create a new document in French (e.g. Sandbox.TestLang) and set this as the content:
        {{velocity}}
        Locale: $xcontext.locale
        {{/velocity}}
        
      5. Go to the document and set the URL parameter language to en (e.g. http://localhost:8080/xwiki/bin/view/Sandbox/TestLang/?language=en)
      6. Go to the document with a browser that accepts english (with a higher priority) and french languages. (do it without any cookies and logged out, with private browsing for instance)

      Expected result

      You should see "Locale: fr" in the document content in both cases.

      Actual result

      "Locale: en" is shown

      Possible solution

      To fix the issue, I propose the following rules to determine the user locale (the one that we find in the context):

      1. Use the locale specified in the URL parameter language only if it is in the supported languages
      2. Use the locale specified in the user cookie only if it is in the supported languages
      3. Use the best supported locale given by the Accept-Language request header sent by the user's browser
      4. Use the default wiki language

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                surli Simon Urli
                Reporter:
                atallahade Adel Atallah
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: