Examples
ContentBlocks fields
The following example system setting in
babeltranslate.translate_resource_cb_fields
manages the translation of
ContentBlocks fields. The first three fields are based on the standard field
configuration that can be installed with ContentBlocks. A field content can be
released for translation directly with the type text
. An existing or
additional text field in a ContentBlocks field can be released for translation
with the type single
or grid
in the fields
array. A repeater can be
released for translation with the type repeater
. ContentBlocks fields within a
repeater are released for translation with the key of the respective field in an
array fields
.
The type text
, single
or grid
is to be used depending on the ContentBlocks
field type.
The following ContentBlocks fields are of type text
:
code
heading
link
quote
richtext
textarea
textfield
The following ContentBlocks fields are of type single
:
image_with_title
The following ContentBlocks fields are of type grid
:
gallery
list
ordered_list
table
file
The following JSON contains some examples of some fields of the standard configuration of ContentBlocks:
{
"1": {
"type": "text"
},
"8": {
"type": "single",
"fields": [
"title"
]
},
"9": {
"type": "grid",
"nested": "images",
"fields": [
"title",
"description"
]
},
"19": {
"type": "repeater",
"repeater": {
"file": {
"type": "grid",
"nested": "files",
"fields": [
"title"
]
}
}
}
}
Repeater
If you want to translate all fields in repeater rows, you only need to add the
type repeater
in the field configuration:
{
"<field-id>": {
"type": "repeater"
}
}
Selected text fields in repeater rows
If you want to translate selected text fields in repeater rows, you need to add
the field names in the repeater
array of the field configuration. The other
fields remain untranslated:
{
"<field-id>": {
"type": "repeater",
"repeater": [
"<text_field_1_name>",
"<text_field_2_name>"
]
}
}
ContentBlocks input types in repeater rows
If you want to translate other ContentBlocks input types (except repeater and
layout) in repeater rows, you can configure each field in the repeater
configuration array (in this case a file input type). If you omit the repeater
configuration, BabelTranslate recognises it automatically and translates every
text field inside:
{
"<field-id>": {
"type": "repeater",
"repeater": {
"file": {
"type": "grid",
"nested": "files",
"fields": [
"title"
]
}
}
}
}
ContentBlocks repeater input type in repeater rows
If you want to translate a ContentBlocks repeater input type in repeater rows,
you can configure the text fields in the rows
array in the repeater
configuration array. When you omit the nested input repeater configuration,
BabelTranslate recognises it automatically and translates every text field
inside:
{
"<field-id>": {
"type": "repeater",
"repeater": {
"<nested_repeater_name>": {
"type": "repeater",
"rows": [
"<nested_text_field_name>"
]
}
}
}
}
ContentBlocks repeater layout type in repeater rows
If you want to translate a ContentBlocks layout input type in repeater rows, you
can to configure the nested layout in the repeater
configuration array. The
fields in the nested layout have to be configured on its own with their field
configuration and can't be configured in this configuration. When you omit the
nested layout configuration, BabelTranslate recognises it automatically:
{
"<field-id>": {
"type": "repeater",
"repeater": {
"<nested_layout_name>": {
"type": "layout"
}
}
}
}
Template variables
The following example system setting in babeltranslate.translate_resource_tvs
manages the translation of template variables fields. A template variable
content can be released for translation directly with the type text
. An
existing nested template variable text can be released for translation with the
type single
or grid
in the fields
array. A custom template variable can be
released for translation with the type custom
and a plugin in the
OnBabelTranslateCustomTV
event.
The type text
, single
or grid
is to be used depending on the template
variable type.
The most template variable types are of type text
.
The following template variable types are of type single
:
imageplus
The following template variable types are of type grid
:
grid
{
"rte": {
"type": "text"
},
"migx": {
"type": "grid",
"fields": [
"title",
"description"
]
},
"imageplus": {
"type": "single",
"fields": [
"title",
"description"
]
},
"special": {
"type": "custom"
}
}