マニュアル キャンセル

サービスプロバイダー向け翻訳フレームワークの設定

RoboHelp を使用してコンテンツを動的に翻訳するために、選択した翻訳サービスプロバイダー向けの翻訳フレームワークを設定する方法を説明します。

すぐに利用できる定義済みの翻訳プロバイダーに加えて、翻訳コネクタを統合して要件に対応することもできます。

翻訳用カスタムスクリプトの使用

カスタムプロバイダーを設定するには、システム上で JavaScript ファイルを作成します。ファイルには、オブジェクトを戻り値として持つ関数が含まれています。この返されるオブジェクトには「呼び出し元」というフィールドがあり、戻り値として JavaScript Promise 型の関数が含まれています。

(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
}
}
(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 } }
(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  
 } 
}

呼び出し元(関数)

返されたオブジェクトの呼び出し元フィールドで定義された関数は、JavaScript Promise を返す JavaScript の「リクエスト」メソッドを使用して、REST API リクエストをサーバーに送信します。Promise の解決 / 拒否に応じて、翻訳されたテキストを返すか、エラーが発生した場合にエラーをスローします。

Bing サンプルスクリプトファイル

(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
}
})
}
}
(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 } }) } }
(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 
                } 
            }) 
        } 
}

上記の例では、Bing translate API について説明しました。Google や Yandex は、Bing とは異なる処理となることに注意してください。サービスプロバイダーが提供する仕様に従って、この関数をビルドします。

RoboHelp インストールディレクトリの下記サンプルを精査することを強くお勧めします。
「resources/data/template/translation/bing/profile_builder.js」
「resources/data/template/translation/google/profile_builder.js」
「resources/data/template/translation/yandex/profile_builder.js」
「resources/data/template/translation/deepl/profile_builder.js」

注意:
  1. 顧客がこれらの翻訳機能を使用すると、データは処理のためにプロバイダーに送信されます。 
  2. そのデータの使用と処理は、プロバイダーとお客様の間の契約およびプロバイダーのプライバシーポリシーによって管理され、Adobe はプロバイダーに対して責任を負いません。

カスタム統合プロファイルの作成

  1. 翻訳プロファイルに移動します。詳細については、「機械翻訳プロファイルの作成」を参照してください。

  2. 新しいプロファイルを作成するには、「+」をクリックします。

  3. 翻訳プロファイルダイアログボックスで、API キーエンドポイントおよびカスタムスクリプトパスの詳細を入力します。

  4. 「検証」をクリックして、入力した資格情報が完全に正しいことを確認します。

  5. 「保存」をクリックします。

ヘルプをすばやく簡単に入手

新規ユーザーの場合