Helper methods for handling multilingual strings.
- Source:
Methods
(static) getSchema(optionsopt) → {TypeObject}
Obtain a Thinky type definition for a multilingual string object which
permits only strings in the supported languages defined in locales/
.
Language keys like 'en' are used as object keys, so you can use syntax like
label.en
, or aliases.fr[0]
for arrays.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
settings for this type definition Properties
|
- Source:
Returns:
type definition
- Type
- TypeObject
(static) resolve(lang, strObj) → {ResolveResult}
Find the best fit for a given language from a multilingual string object, taking into account fallbacks.
Parameters:
Name | Type | Description |
---|---|---|
lang |
String | the preferred language code of the target string |
strObj |
Object | a multilingual string object |
- Source:
Returns:
or undefined if we can't find any suitable string
- Type
- ResolveResult
(static) stripHTML(strObj) → {Object}
Parameters:
Name | Type | Description |
---|---|---|
strObj |
Object | a multilingual string object |
- Source:
Returns:
string object with HTML entities decoded and HTML elements stripped
- Type
- Object
(static) stripHTMLFromArray(strObjArr) → {Array.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
strObjArr |
Array.<Object> | an array of multilingual string objects |
- Source:
Returns:
string object array with HTML entities decoded and HTML elements stripped
- Type
- Array.<Object>