eXo Platform 4.0 Documentation > Reference Guide / GateIn > Portal Development > Pluggable locale policy

2.8.2. Default LocalePolicy

By default, org.exoplatform.portal.application.localization.DefaultLocalePolicyService which is an implementation of LocalePolicy is installed to provide the default behaviour. This, however, can easily be extended and overridden. A completely new implementation can also be written from scratch.

DefaultLocalePolicyService treats logged-in users slightly differently than anonymous users. Logged-in users have a profile that can contain language preference, while anonymous users do not.

Here is an algorithm used for anonymous users.

An algorithm for anonymous users

  1. Iterate over the LocaleContextInfo properties in the following order:

    • cookieLocales

    • sessionLocale

    • browserLocales

    • portalLocale

  2. Get each property's value. If it is a collection, get the first value.

    • If the value is one of the supported locales, return it as a result.

    • If the value is not in the supported locales set, try to remove country information, and check if a language matching locale is in the list of supported locales. If so, return it as a result.

    Otherwise, continue with the next property. If no supported locale is found, the locale is returned to portalLocale by default.

    The algorithm for logged-in users is virtually the same except that the first Locale source checked is user's profile.

An algorithm for logged-in users

  1. Iterate over the LocaleContextInfo properties in the following order:

    • userProfile

    • cookieLocales

    • sessionLocale

    • browserLocales

    • portalLocale

  2. Do the next steps which are the same as for anonymous users.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus