/workspace/getLocale
The getLocale module exports the getLocale method which is required by the getLayer and workspace modules.
- Source
Requires
- module:/utils/roles
- module:/utils/merge
- module:/workspace/mergeTemplates
- module:/workspace/cache
- module:/workspace/getTemplate
Methods
(async, inner) getLocale(params, parentLocaleopt) → {Promise.<(Object|Error)>}
The getLocale method requests the workspace from cache and checks whether the requested locale is a property of the workspace.locales{}.
The workspace.locale is assigned as locale if params.locale is undefined.
Any locale can be nested into another locale, if the locale property is defined as an array of locale keys.
The localeKey will be shifted from the locale array property. The getLocale method will call itself recursively with the locale object provided as parentLocale param. The current locale object will be merged into the parentLocale. The locale key for nested locales is an array which reflects the locale array property.
The locales array property which provides an interface for locales which can be nested but are not available from the workspace.locales directly is removed on nested locales.
The mergeTemplate module will be called to merge templates into the locale object and substitute SRC_* xyzEnvironment variables.
A role check is performed to check whether the requesting user has access to the locale.
Role objects in the locale and nested layers are merged with their respective parent objects.
Template properties will be removed as these are not required by the MAPP API but only for the composition of workspace objects.
Name | Type | Attributes | Description |
---|---|---|---|
params | Object | ||
parentLocale | Object | <optional> | Locale will be merged into optional parentLocale to create a nested locale. |
Name | Type | Attributes | Description |
---|---|---|---|
params.locale | string | <optional> | Locale key. |
params.locale | array | <optional> | An array of locale keys to be merged as a nested locale. |
params.user | Object | <optional> | Requesting user. |
user.roles | Array | <optional> | User roles. |
JSON Locale.
- Type:
- Promise.<(Object|Error)>