QuickNav
TranslationFilter
new TranslationFilter()
A filter to extract translatable strings from OCE assets and re-combine the assets with the translated strings.
- Source:
Members
constraints
Apply constraints to the translation results
Make sure that the translation results will be valid. For example, the "name" attribute of an asset cannot be greater than 64 characters. These regexes will be applied to the complete property path converted to lower case.
For example, an asset has:
Make sure that the translation results will be valid. For example, the "name" attribute of an asset cannot be greater than 64 characters. These regexes will be applied to the complete property path converted to lower case.
For example, an asset has:
{ fields: { Category: 'one', Title: 'a simple example' } }Constraints are applied against the strings:
- "fields"
- "fields.category"
- "fields.title"
- Source:
filters
Filter out the translatable fields from the document
Provide a set of "include" and "exclude" filters for each asset type.
These regexes will be applied to the complete property path converted to lower case.
For example, an asset has:
Provide a set of "include" and "exclude" filters for each asset type.
These regexes will be applied to the complete property path converted to lower case.
For example, an asset has:
{ fields: { Category: 'one', Title: 'a simple example' } }Filtering is applied against the strings:
- "fields"
- "fields.category"
- "fields.title"
- Source:
Methods
applyTranslation(document, translatedDocument, constraintType) → {object}
Re-combine the translated filtered fields with the original document.
Parameters:
Name | Type | Description |
---|---|---|
document |
object | The JSON document to apply the filters to. |
translatedDocument |
object | The JSON document containing the translated string |
constraintType |
"assets" | "site" | the constraint type from TranslationFilter.constraints to apply to the document. |
- Source:
Returns:
A JSON object which is a copy of the base document with the translated strings applied to it.
- Type
- object
getTranslatableProperties(document, filterType, includes) → {object}
Get the translatable strings from the base document.
Parameters:
Name | Type | Description |
---|---|---|
document |
object | The JSON document to apply the filters to. |
filterType |
"assets" | "site" | the filter type from TranslationFilter.filters to apply to the document. |
includes |
object | Array of fields to include by field name. |
- Source:
Returns:
A new JSON object that contains only translatable strings from the given document.
- Type
- object
mergeProperties(args)
Do a deep merge of the properties in the source object into the destination object.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
args |
object | The arguments used by the "mergeProperties" function.
Properties
|
- Source: