Locale

Extends Object. Represents regional information such as country, language, currency and time settings. The locale system is applicable to websites with international settings. 

Properties
country

Type String

The two character ISO code for the country e.g. GB.

countryName

Type String

The name of the country.

currency

Type String

The three character ISO code of the currency for the locale e.g. GBP.

id

Type Number

The system ID for the locale object.

isActive

Type Boolean

True if the locale is current.

language

Type String

The two character ISO code for the language e.g. en.

languageName

Type String

The name of the language.

timezone

Type String

The timezone string for the current locale e.g. Europe/London.



Methods
branch()

Returns Branch

This method returns the closest applicable branch for the locale and is for use on international websites using locales or geotargeting.

Evance allows you to set a branch against a locale if you wish contact details to differ from your main legal entity set in "My Business". This methods implements the following fallback rules:

  1. Returns the Branch assigned to the current locale, else...
  2. Returns the Branch assigned to the Channel, else...
  3. Returns the website's "My Business" details.

This is useful, for example, if you wish to display a different phone number on a US locale to your default GB locale.

{{ website.locale.branch.phone }}

Note this is an alternative to shop.phone and may not be implemented in themes by default. However, the object is available to all themes whether internationalisation is included in your current plan, or not.

href([Mixed:url])

Returns Url

This method returns a locale safe Url that switches the user to a new preferred locale and redirects the user back to the Url supplied, or the current page if not supplied. This is an important method for switching between languages or locales on multi-regional websites that have strict geo-targeting enabled. 

In the example below we want to cycle through all of the available locales for a multi-regional website and then link to the homepage of each region:


<?ev for(var locale of website.locales){ ?>
    <a href="{{ locale.href('/') }}">{{ locale.countryName }} - {{ languageName }}</a>
<?ev } ?>

The resulting Urls in the href attribute will look something like the following:

/locale?set=en-us&direct=Lw%3D%3D

Note this is the only locale safe method of switching between locales on multi-regional websites with strict geo-targeting. A cookie will be set to save the user's preferred locale on repeat visits to the website.

manager()

Returns Contact

This method returns the closest applicable manager Contact for the locale.

Evance allows you to set a manager against a locale if you wish contact information to differ from the Account Owner. This methods implements the following fallback rules:

  1. Returns the Contact assigned as manager for the current locale, else...
  2. Returns the Contact assigned as manager for the Channel, else...
  3. Returns the website's Account Owner details.

This is useful, for example, if you wish to display contact information should visitors wish to get in contact with the relevant manager for the locale.

{{ website.locale.manager }}

Note please exercise caution when displaying manager information on your public website.