google translate optimized

This commit is contained in:
Akash Mozumdar 2018-12-18 14:21:27 -05:00
parent 3c67f5a15d
commit 5523644ef9

View File

@ -153,6 +153,8 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
static unsigned TKK = 0;
std::wstring translation;
if (internet)
{
if (!TKK)
{
if (HINTERNET connection = WinHttpConnect(internet, L"translate.google.com", INTERNET_DEFAULT_HTTPS_PORT, 0))
{
@ -170,6 +172,8 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
}
WinHttpCloseHandle(connection);
}
}
if (HINTERNET connection = WinHttpConnect(internet, L"translate.google.com", INTERNET_DEFAULT_HTTPS_PORT, 0))
{
@ -191,6 +195,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
translation += std::wstring(results[1]) + L" ";
for (auto& c : translation) if (c == L'\\') c = 0x200b;
}
else TKK = 0;
}
WinHttpCloseHandle(request);
}