Documentation

LocalizationTrait

Table of Contents

Properties

$locale  : string|null
$requestedLocale  : string|null
The language that was requested to be rendered.

Methods

getLocale()  : string
getRequestedLocale()  : string
Get the requested locale.
setLocale()  : $this
setRequestedLocale()  : $this
Set the requested locale.
validateExtra_localization()  : mixed

Properties

$requestedLocale

The language that was requested to be rendered.

protected string|null $requestedLocale

This may not be the rendered locale - as the requested language might be available. This is primarily for extensions to use in custom workflow messages.

The use-case is a bit like this:

  1. Your organization serves many similar locales (eg es_MX+es_CR+es_HN or en_GB+en_US+en_NZ).
  2. You want to write one message (es_MX) for several locales (es_MX+es_CR+es_HN)
  3. You want to include some conditional content that adapts the recipient's requested locale (es_CR) -- even though the template was stored as es_MX. For example your front end website has more nuanced translations than your workflow messages and you wish to redirect the user to a page on your website.
Tags
scope

tokenContext

Methods

getRequestedLocale()

Get the requested locale.

public getRequestedLocale() : string

This may differ from the rendered locale (e.g. if a translation is not available). It is not used in core but extensions may leverage this information.

Return values
string

setLocale()

public setLocale(string|null $locale) : $this
Parameters
$locale : string|null
Return values
$this

setRequestedLocale()

Set the requested locale.

public setRequestedLocale(string|null $requestedLocale) : $this
Parameters
$requestedLocale : string|null
Return values
$this

validateExtra_localization()

protected validateExtra_localization(mixed &$errors) : mixed
Parameters
$errors : mixed

        
On this page

Search results