System Settings
BabelTranslate contains some system settings in the babeltranslate
namespace.
These are available in the MODX system settings panel.
Key | Name | Description | Default |
---|---|---|---|
babeltranslate.debug | Debug | Log debug information in the MODX error log. | No |
babeltranslate.deepl_auth_key | DeepL API Auth Key | The DeepL auth key to access the DeepL API. | - |
babeltranslate.deepl_text_translation_options | DeepL Text Translation Options | [Since 1.2.3] JSON-encoded object of DeepL text translation options. The options can be found in the DeepL API Docs. @FILE or @CHUNK bindings can be used. |
- |
babeltranslate.openai_api_url | OpenAI API Url | [Since 1.5.0] The OpenAI compatible service URL | - |
babeltranslate.openai_auth_key | OpenAI API Auth Key | [Since 1.5.0] The OpenAI auth key to access to the OpenAI API. | - |
babeltranslate.openai_metadata | OpenAI Chat Metadata | [Since 1.5.0] JSON-encoded object of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format and for querying objects via the API or the Dashboard. | - |
babeltranslate.openai_model | OpenAI Model | [Since 1.5.0] The model ID used to generate the response, such as gpt-4o or o1 . OpenAI offers a wide range of models with different capabilities, performance characteristics and price points. |
- |
babeltranslate.openai_temperature | Temperature | [Since 1.5.0] The sampling temperature to use (between 0 and 1). Higher values such as 0.8 will make the output more random, while lower values such as 0.2 will make it more focused and deterministic. |
- |
babeltranslate.openai_text_translation_options | Text translation instructions | [Since 1.5.0] Instructions to the model on how to approach the translation task. Could be used to give instructions on formality, tone of voice or specific vocabulary to use. @FILE or @CHUNK bindings can be used. |
- |
babeltranslate.reverso_api_url | Reverso API Url | [Since 1.3.0] The API url for accessing the Reverso API | - |
babeltranslate.reverso_password | Reverso Password | [Since 1.3.0] The password to access the Reverso API. | - |
babeltranslate.reverso_text_translation_options | Reverso Text Translation Options | [Since 1.3.0] JSON-encoded object of Reverso text translation options. @FILE or @CHUNK bindings can be used. |
- |
babeltranslate.reverso_username | Reverso Username | [Since 1.3.0] The Reverso username to access the Reverso API. | - |
babeltranslate.translate_duplicate | Translate Babel Duplicate | Translate the duplicate Babel resource directly. | No |
babeltranslate.translate_resource_cb_fields | Translate ContentBlocks Fields | JSON-encoded object of ContentBlocks fields that need to be translated. Each record contains the ContentBlocks field ID as a key, the value contains several options: type is optional (it is otherwise set by the ContentBlocks field type) and can be filled with text , single , grid or repeater . nested is optional (it is otherwise set by the ContentBlocks field type) and it can contain the key of the nested values in the ContentBlocks value. fields is optional (it defaults to ["value"] ) and it can be filled with an array of field names which will be translated. @FILE or @CHUNK bindings can be used. |
- |
babeltranslate.translate_resource_fields | Translate Fields | Comma-separated list of resource fields that need to be translated. @FILE or @CHUNK bindings can be used. |
pagetitle, longtitle, content, alias |
babeltranslate.translate_resource_tvs | Translate Template Variables | JSON-encoded object of template variables that need to be translated. Each record contains the template variable name as a key, the value contains several options: type is optional (it is otherwise set by the template variable type) and can be filled with text , single , grid or custom . fields is optional (it defaults to ["value"] ) and it can be filled with an array of field names which will be translated. @FILE or @CHUNK bindings can be used. |
- |
babeltranslate.translator | Translator service | The main translator service. Defaults to the first available translator service in the babeltranslate.translators system setting. |
deepl |
babeltranslate.translators | Translator services | [Since 1.3.1] Comma-separated list of translator services (deepl and reverso are currently possible). The first available translator service for each language is used. |
deepl |
Examples for the babeltranslate.translate_resource_cb_fields
and
babeltranslate.translate_resource_tvs
settings can be found on the
examples page.
The settings babeltranslate.translate_resource_fields
,
babeltranslate.translate_resource_tvs
and
babeltranslate.translate_resource_cb_fields
can use @FILE
or @CHUNK
bindings. Path placeholders like {core_path}
, {base_path}
and
{assets_path}
can be used. All paths have to stay inside the MODX base path
because of security reasons.
Custom template variable translation type
The custom
type of babeltranslate.translate_resource_tvs
will be handled by a
plugin in OnBabelTranslateCustomTV
. There exist a disabled skeleton plugin in
the BabelTranslate category. Duplicate and edit that plugin to add your own
translation handling.
The plugin can use the following event properties:
Property | Content |
---|---|
translator | The translator class. Translating a string is done by $translator->translate($string, $fromCulture, $toCulture) . |
resource | The current translated resource. |
tvname | The name of the translated template variable. |
value | The value of the translated template variable. |
fromCulture | The culture the value is translated from. |
toCulture | The culture the value is translated to. |