例如,如何將指定的英文內容翻譯成中文?
這是 GPT3.5 查詢的結果,不起作用。
謝謝!
url = "https://translate.google.com";
sourceText = "Hello, world!";
targetLanguage = "zh-CN"; // Chinese Simplified
// Build the HTTP request
postData = "sl=en&tl=" || urlEncode(targetLanguage) || "&text=" || urlEncode(sourceText);
headers = Associative Array("Content-Type", "application/x-www-form-urlencoded", "User-Agent", "Mozilla/5.0");
httpReq = New HTTP Request(
url,
"POST",
headers,
postData
);
// Send the HTTP request and retrieve the response
httpReq.Send();
response = httpReq.ResponseBody();
// Extract the translation
startPos = Pos(response, "<SPAN title="\">", startPos); Translation = Substr(response, startPos, endPos - startPos); // 顯示翻譯結果 Show("來源文字: " || sourceText); Show("翻譯: " || Translation);</SPAN>您的範例中使用了許多不正確的函數。我會先使用腳本索引來修復這些問題,然後在需要時回到這裡。