beforeDispatch(\Cake\Event\Event $event) : void
Prepares the default language to use by the script.
This method applies the following detection methods when looking for language to use:
GET parameter: If
localeGET parameter is present in current request, and if it's a valid language code, then will be used as current language and also will be persisted on
localesession for further use.
URL: If current URL is prefixed with a valid language code and
url_locale_prefixoption is enabled, URL's language code will be used.
Locale session: If
localesession exists it will be used.
User session: If user is logged in and has selected a valid preferred language it will be used.
- Default: Site's language will be used otherwise.
url_locale_prefix option is enabled, and current request's URL is not
language prefixed, user will be redirected to a locale-prefixed version of
the requested URL (using the language code selected as explained above).
Might redirects to:
containing the request, response and additional parameters
When no valid request object could be found