Configure a translation framework for a service provider

Learn how to configure the Translation framework for a translation service provider of your choice to dynamically translate your content with RoboHelp.

In addition to the pre-defined translation providers available out-of-the-box, you can also integrate your translation connector to serve your requirements.  

Using custom script for translation

To configure a custom provider, create a JavaScript file on the system. The file contains a function with return value an object. This returned object has a field “caller” and has a function of return type JavaScript Promise as its value.

(src_lng, tar_lng, text2translate, API_KEY, endpoint) => { 
 //src_lang: source language 
 //tar_lang: target language 
 //text2translate: text to send for translation 
 //API_KEY: API key from your service provider 
 //endpoint: endpoint/API URL of your service provider 
 //build your query  
 var query:Function = //REST API goes here, which returns a Promise 
 return { 
  caller: query  
 } 
}

caller (Function)

The function defined in the caller field of the returned object sends the REST API request over to the server using javascript "request" method, which returns a javascript Promise. Resolve/reject the Promise accordingly and finally return the translated text or in case of an error, throw an error.

Bing sample script file

(src_lng, tar_lng, text2translate, API_KEY, endpoint) => { 
     const uuidv4 = require('uuid/v4'); 
   const request = require('request'); 
 var api_request_fn = () => { 
   // return a promise because sending and receiving translated text is asynchronous procedure 
            return new Promise((resolve, reject) => {  
   var request_data = { 
              method: 'POST', 
              baseUrl: endpoint, 
              url: 'translate', 
              qs: { 
                'api-version': '3.0', 
                'to': [tar_lng] 
              }, 
              headers: { 
                 'Ocp-Apim-Subscription-Key': API_KEY, //your API key goes here 
                 'Content-type': 'application/json', 
                 'X-ClientTraceId': uuidv4().toString() //give an ID to your request 
              }, 
              body: [{ 
                    'text': text2translate //send the text to translate as a part of the body 
              }], 
              json: true, 
          }  
   // the structure of request_data is different for every service provider 
   // look up the documentation provided by your translation service provider  
   // to build the request data. 
 
                request(request_data, function(err, res, body) {  
     // read about request method here https://www.npmjs.com/package/request 
                    if(err) {// in case of an error reject the promise, it will exit the translation process 
                        reject({body, err, res}) 
                    } else {// in case of a valid response from the server, resolve the promise 
                        resolve({body, err, res}) 
                    } 
                }) 
            }).then(data => { 
                if(data.body.error) { 
     // in case error from the server is send as part of the body  
     // and skipping the previous if block in request, handle it here  
                    throw new Error(data.body.error.message); 
     // throw the error with the message you want to show,  
     // preferably the error message sent by the server 
                } else { 
                    return data.body[0].translations[0].text  
     // return the translated text here, in this case it is in the data at  
     // the specified location. The location in the data object varies with the provider 
                } 
            }) 
        } 
}

We discussed Bing translate API builder in the above example, notice that google and yandex have different handlers than the Bing. Build this function according to the specifications provided by your service provider.

We strongly recommend to check out samples in your RoboHelp installation directory:   
"resources/data/template/translation/bing/profile_builder.js"
"resources/data/template/translation/google/profile_builder.js"
"resources/data/template/translation/yandex/profile_builder.js"

הערה:
  1. When customers use these translation features, the data is submitted to the vendor for the purpose of processing. 
  2. The use and processing of that data is governed by the customer’s contract with the vendor and the vendor’s privacy policy, and Adobe is not responsible for the vendor.

Create a custom integration profile

  1. Navigate to Translation Profiles. For details, see Create profile for Machine Translation.

  2. Click + to create a new profile.

  3. In the Translation profile dialog box, provide the details for API key, Endpoint & Custom Script Path

  4. Click Validate to verify that the credentials entered are correct and complete.

  5. Click Save.

לוגו של Adobe

כניסה לחשבון