You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 49 Next »

What is locale

Unable to render {include} The included page could not be found.

Two locales in Magnolia

The question of "two locales" is connected with the types of users who access a Magnolia instance.

An ordinary internet user, new or returning – whom we can call public user – will usually only be able to see and interact with the pages of a published web project or website. The user will be interacting – via the web browser – with a running public instance of Magnolia and will expect that the content of each page on the site will be available in a language he can understand, ideally in his native language. A user who's native language is English will prefer browsing the English language version of a website (the screenshots are from the Travel Demo):

On the other hand, a Magnolia editor/publisher (user) or sysadmin – let's for now use the term system user – working with the author instance of Magnolia may have different locale preferences than the public user. A system user's native and hence preferred language may be, for example, Spanish but the content being edited may still be in the English language. The system user would probably welcome if

in the author instance (see also Types of translatable text) were displayed in Spanish rather than in English:

Magnolia has been built to deal with these two separate  locale preferences, that is with 

  • Site Locale
  • AdminCentral Locale.

Determining and setting the latter is fairly straightforward since the system users will usually know which locale they prefer. They can also set the locale themselves directly in the AdminCentral or they may always ask a user with superuser rights to set the preferred locale for them. To determine site locale is slightly more difficult. Public users usually access web pages as anonymous users. Magnolia then has to rely on indirect means that point to the preferred locale of a public user.

Please note that on this page, by site locale we mean a concrete language variant in which a web project's page can be rendered on a public user's device. In Magnolia, there are also other uses of "site", such as in Site module or website (a workspace name).

AdminCentral locale

The AdminCentral locale primarily defines the language of User interface labels that the system user wants to work with in the AdminCentral, for example the language of labels in the Action bar (English on the left, Korean on the right):

An incomplete localisation of a UI element may result in displaying a label in the fallback language, as shown below in the case the Copy page and Paste page actions:

Configuring the AdminCentral locale

When logged-in in the AdminCentral, users may set their language locale parameter via the Language field in the Edit user profile dialog. The setting will be reflected in the names of action menus, actions, buttons and labels throughout the AdminCentral provided the locale is one of the available system languages or it will fallback to English, the default fallback language but configurable

To set it, open the pull down menu in the top right corner of the browser window and click the first row of the menu, titled Edit user profile if the current locale setting is English. On the Preferences tab:

The new locale will be applied the next time you log in into the AdminCentral.

Site locale

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

From the User-Agent header

While occassionally containing information such as en_US , for example in 

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

this locale information in the User-Agent header

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

    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.

From the Accept-Language header

The Accept-Language request header of an HTTP request defines which languages variant of a requested page would by preferred by the public user. This locale information may take one of the following three forms:

  • <language>
  • <locale>
  • *

The first represents language expressed as a 2 or 3-character string, the second represents language as a full language tag, the third says "any language" (see Accept-Language and Language Tags in RFC-2616).

A site in Magnolia may be configured to look set the site's locale according to the information provided in this header, see the configuration section below.

From Request-URI


Configuring site locale

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels