Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The setting of a site locale influences the editorial content and template labels and unless a public user registers to a web product/service and actively provides the locale information to the webapp, the webserver has to rely on other means that could help identify the visitors preferred locale.

Determining the preferred site locale

...

There are a number of ways of obtaining some form of locale information. Some of them use advanced techniques such as geolocation based on ping delay or topology, but one of the most common way is to look into the content of a HTTP request. At least the following three parts of an HTTP request are relevant to the identification of the public user's locale:

  • the User-Agent header
  • the Accept-Language header
  • Request-URI

User-Agent

While it may occassionally contain some locale informationcontaining information such as en_US , for example the en_US part in 

Code Block
Mozilla/5.0 (compatible; Konqueror/4.5; NetBSD 5.0.2; X11; amd64; en_US) KHTML/4.5.4 (like Gecko)

the this locale information in the User-Agent header is

  • usually redundant, 
  • identifies the language variant of the software sending the request rather than the software's user's preferred locale, and 
  • is usually redundant, 
  • and more often than not will be even is missing:

    Code Block
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

...

Magnolia has no direct means how to check for the existence of and retrieve this type of locale information. The preferred locale information is communicated via the Accept-Language header.

...