/workspace/getLocale

The getLocale module exports the getLocale method which is required by the getLayer and workspace modules.

Requires

Methods

(async, inner) getLocale(params, parentLocaleopt) → {Promise.<(Object|Error)>}

Nested locales can be requested by providing an array of locale keys. The first locale key will be used to retrieve the locale object and the remaining locale keys will be merged into the first locale as nested locales.

The getLocale method will return an error if the requesting user does not have access to the locale.

Parameters:
NameTypeAttributesDescription
paramsObject
parentLocaleObject<optional>

Locale will be merged into optional parentLocale to create a nested locale.

Properties
NameTypeAttributesDescription
params.localestring<optional>

Locale key.

params.localearray<optional>

An array of locale keys to be merged as a nested locale.

params.userObject<optional>

Requesting user.

user.rolesArray<optional>

User roles.

params.layersBoolean<optional>

Whether to retrieve layers for the locale.

Returns:

JSON Locale.

Type: 
Promise.<(Object|Error)>

(inner) localeAttribute(localeopt) → {string}

Returns the locale param as a string span attribute.

Parameters:
NameTypeAttributesDescription
localestring | array | object<optional>

The locale param.

Returns:

The locale key.

Type: 
string

(async, inner) mergeParentLocale(locale, parentLocaleopt)

Merges a child locale into a parent locale, composing their properties and updating the nested locale structure.

Parameters:
NameTypeAttributesDescription
localeObject

The locale object to compose.

parentLocaleObject<optional>

Optional parent locale to merge into.

(async, inner) resolveLocale(params, parentLocaleopt) → {Promise.<(Object|Error)>}

Resolves the locale for the getLocale method.

Parameters:
NameTypeAttributesDescription
paramsObject
parentLocaleObject<optional>

Locale will be merged into optional parentLocale to create a nested locale.

Returns:

JSON Locale.

Type: 
Promise.<(Object|Error)>

(async, inner) workspaceLocale(workspace, params) → {Promise.<(Object|Error)>}

Returns a clone of the locale for the first locale key in the params.locale. The first key is removed from a params.locale array, the remaining keys are nested locales.

The locale is looked up in the workspace.locale, the workspace.locales, or the workspace templates. A locale object provided as locale key is cloned.

Parameters:
NameTypeDescription
workspaceworkspace

The cached workspace.

paramsObject
Properties
NameTypeAttributesDescription
params.localestring | array | object<optional>

Locale key, array of locale keys, or locale object.

Returns:

JSON Locale or the getTemplate error.

Type: 
Promise.<(Object|Error)>