Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

次のコードを Initialize イベントに追加します。

* サーバー・モジュールのオブジェクト作成

     Define_Com Class(#GoogleTranslateServerModule.Translate) Name(#Translator)

* 翻訳されたテキスト、エラー・メッセージ、ステータスを保持する変数

     Define_Com Class(#PRIM_DC.UnicodeString) Name(#TranslatedText)
Define_Com Class(#PRIM_DC.UnicodeString) Name(#ErrorMessage)
Define_Com Class(#PRIM_BOLN) Name(#OK)

* サーバー・モジュールの起動

     #Translator.Execute Sourcetext('This is so cool!') Sourcelanguage('en') Targetlanguage('fr') Translatedtext(#TranslatedText) Ok(#OK) Errormessage(#ErrorMessage)

* 結果の表示 (OK の場合)、またはエラー・メッセージ (失敗した場合)

     If (#OK)
  #SYS_WEB.Alert Caption('The translated text in French: ' + #TranslatedText)
Else
  #SYS_WEB.Alert Caption('An error has occurred: ' + #ErrorMessage)
Endif

API キーが正しく設定されていれば、Web ページ実行時、次のように表示されるはずです。


次は: 次は:翻訳のためのコードを再利用可能パーツにまとめる