mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
parent
903b2c2a73
commit
c7b5dd1f0a
@ -58,7 +58,7 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
var input = "{\"q\": \"" + Json.EncodeJsonText(text.Trim()) + "\", \"source\": \"" + sourceLanguageCode + "\", \"target\": \"" + targetLanguageCode + "\"" + apiKey + "}";
|
||||
var content = new StringContent(input, Encoding.UTF8);
|
||||
content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
|
||||
var result = _httpClient.PostAsync("translate", content).Result;
|
||||
var result = _httpClient.PostAsync("translate", content, cancellationToken).Result;
|
||||
var bytes = await result.Content.ReadAsByteArrayAsync();
|
||||
var json = Encoding.UTF8.GetString(bytes).Trim();
|
||||
if (!result.IsSuccessStatusCode)
|
||||
@ -74,6 +74,9 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
resultText = resultText.Replace("<br />", Environment.NewLine);
|
||||
resultText = resultText.Replace(" /> ", " "); // https://github.com/SubtitleEdit/subtitleedit/issues/8223
|
||||
|
||||
return Json.DecodeJsonText(resultText).Trim();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user