Skip to content

Commit

Permalink
deepl bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Sep 6, 2021
1 parent 6c74df8 commit 574eeec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion extensions/devtoolsdeepltranslate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ std::pair<bool, std::wstring> Translate(const std::wstring& text, TranslationPar
// DevTools can't handle concurrent translations yet
static std::mutex translationMutex;
std::scoped_lock lock(translationMutex);
DevTools::SendRequest("Page.navigate", FormatString(LR"({"url":"https://www.deepl.com/en/translator#en/en/%s"})", Escape(text)));
std::wstring escaped; // DeepL breaks with slash in input
for (auto ch : text) ch == '/' ? escaped += L"\\/" : escaped += ch;
DevTools::SendRequest("Page.navigate", FormatString(LR"({"url":"https://www.deepl.com/en/translator#en/en/%s"})", Escape(escaped)));
for (int retry = 0; ++retry < 20; Sleep(100))
if (Copy(DevTools::SendRequest("Runtime.evaluate", LR"({"expression":"document.readyState"})")[L"result"][L"value"].String()) == L"complete") break;

Expand Down

0 comments on commit 574eeec

Please sign in to comment.