Whatever message this page gives is out now! Go check it out!

サービスプロバイダー用の翻訳フレームワークを設定する

Last update:
2024/01/24
任意の翻訳サービスプロバイダー向けに翻訳フレームワークを設定し、RoboHelpでコンテンツを動的に翻訳する方法を説明します。
標準で利用できる定義済みの翻訳プロバイダーに加えて、要件に合わせて翻訳コネクタを統合することもできます。

翻訳にカスタムスクリプトを使用する

カスタムプロバイダーを設定するには、システム上にJavaScriptファイルを作成します。 このファイルには、オブジェクトを戻り値として返す関数が含まれます。この返されたオブジェクトには「caller」フィールドがあり、その値として戻り値の型が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  
 } 
}

caller (関数)

返されたオブジェクトのcallerフィールドで定義された関数は、JavaScriptの「request」メソッドを使用してREST APIリクエストをサーバーに送信し、JavaScript Promiseを返します。これに応じてPromiseをresolve/rejectし、最後に翻訳されたテキストを返すか、エラーが発生した場合はエラーを返します。
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 
                } 
            }) 
        } 
}
上記の例ではBing翻訳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"
Note:
  1. 顧客がこれらの翻訳機能を使用すると、処理を目的としてデータがベンダーに送信されます。
  2. そのデータの使用と処理は、顧客とベンダーとの契約およびベンダーのプライバシーポリシーに従うものであり、Adobeはベンダーに対して責任を負いません。

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

  1. 翻訳プロファイルに移動します。詳しくは、機械翻訳用のプロファイルを作成を参照してください。
  2. 新しいプロファイルを作成するには、 + をクリックします。
  3. 「翻訳プロファイル」ダイアログボックスで、APIキー、エンドポイント、カスタムスクリプトパスの詳細を指定します。 
  4. 入力した資格情報が正しく完全であることを確認するには、検証をクリックします。
  5. 保存をクリックします。
このページは役に立ちましたか?
お役に立ててうれしいです。このページがどのように役立ったか教えてください。
申し訳ございません。どのような点が問題だったか教えてください。
フィードバックありがとうございます。いただいたご意見はこのページの改善に役立てさせていただきます。

このページの内容