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: boolean

  • excludeStrings: string

  • regexpMatch: string

  • regexpReplace: string

{
    "components": {
        "preTranslation":{
            "allowLineBreaks": true,
            "regexpReplace": "[\"\\n\", \"g\", \"\\\\n \"]"
        }
    }
}

postTranslation

Processes the translated text after receiving it from the translation service.

  • regexpMatch: string

  • regexpReplace: string

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>

usageChecker

  • interval: number - Interval in milliseconds between usage checks

  • format: string - Display format for usage information

  • request: object - Request configuration for checking usage:

    • method: string - HTTP method ("http_get", "http_post")

    • url: string - API endpoint URL for usage information

    • body: object (optional) - Request body for POST requests

    • options: object (optional) - Additional request options:

      • headers: object - Custom request headers

    • responseCountQuery: string - JSON path to extract current usage count

    • responseLimitQuery: string - JSON path to extract usage 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 prepending

    • value: string - Text to prepend

  • appendSourceText: object - Adds text after the source text:

    • status: boolean - Enable or disable appending

    • value: string - Text to append

  • replaceSourceText: object - Replaces the entire source text