Skip to main content
Website Translation Tool

Expanding WEB-T with new machine translation

 Providers:

Integrating a new machine translation (MT) provider into the WEB-T ecosystem is a straightforward process. By creating a dedicated MT provider proxy that supports two essential methods, you can easily expand our services:

  1. Listing available MT systems: This method provides an overview of available MT systems, including language pairs and domains.
  2. Translation method: This method forwards translation requests to the selected MT Provider.

The proxy's key functions include translating requests and responses between the WEB-T generic MT API and your specific MT provider API. Additionally, it handles authentication, which can vary significantly for each MT provider. For authorization, WEB-T plugins set the 'X-API-KEY' header in all requests using the user's API key.

To add support for your MT Provider in WEB-T website translation solutions: 

  • Create Generic MT API proxy. 
    Implement authentication via user specific API key, which will map user's API key (from WEB-T plugin settings) to your MT provider API authentication. For example, if your MT service uses username and password for authentication, you can create a database table that maps each proxy API key to a username and password pair. If your MT service does not use any kind of authentication, you can skip this step. 
  • Implement Language directions method, which will retrieve available systems from your MT provider API. See section Language directions method for technical details. Implement Translation method, which will translate text via your MT provider API.
     
  1. See section Translation method for technical details. 
  2. Publish your proxy online. 
  3. To each user give proxy URL and API key, which can be entered into plugins. 

Language directions method 

This method allows the WEB-T solutions to find out what language directions / MT systems are available and can be used for machine translation. 

Language directions response will fetch language directions from all configured providers as shown in the next code fragments. Each provider’s language directions will differ by vendor field. 

  1. Request 

HTTP GET /translate/language-directions 

Query params [Optional] 

All of the query parameters are optional and can be used to filter language directions: 

  • srcLang (string) – source language code (e.g., ‘en’) 
  • trgLang (string) – target language code (e.g., ‘de’) 
  • domain (string) – MT system domain (e.g., ‘General’) 
     
  1. Response 

Response is in JSON format and consists of the languageDirections array, which lists objects that contain information about each machine-translation system that is available. This information is: 

  • id - system ID (string). 
  • srcLang – source language (string). 
  • trgLang – target language (string). 
  • domain – system domain (string). 
  • vendor – system vendor name (string), useful if the provider offers MT systems from multiple sources. 

Response body example:

{

  "languageDirections":[

    {  

        "srcLang": "en",

          "trgLang": "de",

          "domain": "General",

          "vendor": "eTranslation"

      }

...

  ]

}

Translation method 

This method allows the WEB-T solutions to machine translate any text during website translation process. 

  1. Request 

HTTP POST /translate/text 

Request body is a JSON object, which must contain the following data: 

  • srcLang (string) – source language code. 
  • trgLang (string) – target language code. 
  • domain (string) – system domain, optional; if no domain is specified, then the first available language direction of the domain will be used. 
  • text (string[]) – array of translatable strings. 

In addition to X

Request body example:

{

  "srcLang": "en",

  "trgLang": "de",

  "domain":

"General",

  "text": [  

    "First segment",  

    "Second segment"  

]

}

 

  1. Response 

Response is a JSON object, consisting of the following data: 

  • translations (object[]) – array of translation objects. 
    a) translation (string) – translation for each source text sent in the request. 
  • domain (string) – domain for the system that was used to machine-translate source strings. If the domain was not specified upon request, then the domain that was used will be returned here. Otherwise – the requested domain. 

Response body example:

{

  "domain":

"domain",

 "translations": [

     {

          "translation": "Translation of first segment"

      },      

    {          

        "translation": "Translation of second segment"

      }  

]

}

 

  1. HTTP response codes used 
  • 200 – Success 
  • 400 – Missing or incorrect parameters 
  • 404 – Language direction is not found 
  • 413 – Maximum text size limit reached for the request 
  • 429 – Too many requests 
  • 500 – An unexpected error occurred 
  • 504 – Request timed out 

Error responses return JSON objects with the following data: 

  • error (object) – error object. 
  • code (integer) – MT proxy specific error code. 
  • message (string) – error message. 

Error response body example:

{

  "error":

  {

  "code": 500001,

  "message": "Error message"

  }

}

 

For assistance with expanding WEB-T with a new machine translation provider, please consult the WEB-T Helpdesk

WEB-T Helpdesk