Components
This is a configuration section of Custom MT. Components are declared as objects within the configuration:
{
"components": {
"preTranslation": {},
"postTranslation": {},
"contextMemory": {},
"usageChecker": {},
"interceptorRequest": {}
}
}preTranslation
Processes the source text before sending it to the translation service.
allowLineBreaks:
booleanexcludeStrings:
stringregexpMatch:
stringregexpReplace:
string
{
"components": {
"preTranslation":{
"allowLineBreaks": true,
"regexpReplace": "[\"\\n\", \"g\", \"\\\\n \"]"
}
}
}postTranslation
Processes the translated text after receiving it from the translation service.
regexpMatch:
stringregexpReplace:
string
{
"components": {
"postTranslation": {
"regexpReplace": "[\"\\\\\\\\n\", \"g\", \"\\n\"]"
}
}
}contextMemory
Maintains context history for AI/LLM translations, allowing the model to reference previous dialogue for improved coherence and accuracy.
Required Parameters
schema:
Array of objects<{type: string, name: string, default: string|number|bool}>formBuilder:
Array of objects<{type: string, form: string, name: string, default: string|number}>components:
object- Component reference to schema name <schema:string>
{
"schema": {
{ "type": "boolean", "name": "contextMemory.status", "default": true },
{ "type": "string", "name": "contextMemory.initial_prompt", "default": "" },
{ "type": "string", "name": "contextMemory.system_template", "default": "" },
{ "type": "string", "name": "contextMemory.user_template", "default": "[{ \"role\": \"user\", \"parts\":[{\"text\":\"$SOURCE_TEXT\"}] }]" },
{ "type": "string", "name": "contextMemory.assistant_template", "default": "[{ \"role\": \"model\", \"parts\":[{\"text\":\"$TRANSLATED_TEXT\"}] }]" },
{ "type": "string", "name": "contextMemory.data_source", "default": "new_translation" },
{ "type": "number", "name": "contextMemory.max_entries", "default": "1" },
},
"formBuilder": {
{ "type": "string", "form": "textarea", "width": "450", "name": "contextMemory.user_template", "default": "", "title": "User Template" },
{ "type": "string", "form": "textarea", "width": "450", "name": "contextMemory.assistant_template", "default": "", "title": "Assistant Template" },
{ "type": "string", "form": "select", "name": "contextMemory.data_source", "title": "Context Source", "default": "TM",
"options": [
{ "name": "New Translation History", "value": "new_translation" },
{ "name": "Translation Memory", "value": "TM" }
]
},
{ "type": "number", "form": "range", "name": "contextMemory.max_entries", "title": "Max Context Entries", "default": "1", "min": "1", "max": "256", "step": "1" }
},
"components": {
"contextMemory": {
"schema": "contextMemory"
}
}
}usageChecker
interval:
number- Interval in milliseconds between usage checksformat:
string- Display format for usage informationrequest:
object- Request configuration for checking usage:method:
string- HTTP method ("http_get","http_post")url:
string- API endpoint URL for usage informationbody:
object(optional) - Request body for POST requestsoptions:
object(optional) - Additional request options:headers:
object- Custom request headers
responseCountQuery:
string- JSON path to extract current usage countresponseLimitQuery:
string- JSON path to extract usage limit
{
"components": {
"usageChecker": {
"interval": 60000,
"format": "( $COUNT / $LIMIT )",
"request": {
"method": "http_get",
"url": "https://api.deepl.com/v2/usage?auth_key=$API_KEY",
"responseCountQuery": "character_count",
"responseLimitQuery": "character_limit"
}
}
}
}interceptorRequest
Modifies the source text before sending it to the translation service.
prependSourceText:
object- Adds text before the source text:status:
boolean- Enable or disable prependingvalue:
string- Text to prepend
appendSourceText:
object- Adds text after the source text:status:
boolean- Enable or disable appendingvalue:
string- Text to append
replaceSourceText:
object- Replaces the entire source text
{
"schema": {
{ "type": "boolean", "name": "interceptorRequest.prependSourceText", "default": false },
{ "type": "string", "name": "prompt", "default": "Translate the following text from $SOURCE_LANG to $TARGET_LANG: " }
},
"components": {
"interceptorRequest":{
"prependSourceText": {
"status": false,
"value": "$PROMPT"
}
}
}
}