diff --git a/extensions/bingtranslate.cpp b/extensions/bingtranslate.cpp index 7ee526d..9310833 100644 --- a/extensions/bingtranslate.cpp +++ b/extensions/bingtranslate.cpp @@ -83,7 +83,7 @@ QStringList languages bool translateSelectedOnly = false, rateLimitAll = true, rateLimitSelected = false, useCache = true; int tokenCount = 30, tokenRestoreDelay = 60000, maxSentenceSize = 500; -std::pair Translate(const std::wstring& text, SentenceInfo) +std::pair Translate(const std::wstring& text) { if (!apiKey->empty()) if (HttpRequest httpRequest{ diff --git a/extensions/deepltranslate.cpp b/extensions/deepltranslate.cpp index a738627..ebeff7b 100644 --- a/extensions/deepltranslate.cpp +++ b/extensions/deepltranslate.cpp @@ -25,13 +25,13 @@ QStringList languages "Spanish: ES", }; -bool translateSelectedOnly = true, rateLimitAll = true, rateLimitSelected = true, useCache = false; +bool translateSelectedOnly = true, rateLimitAll = true, rateLimitSelected = true, useCache = true; int tokenCount = 10, tokenRestoreDelay = 60000, maxSentenceSize = 500; const wchar_t* accept[] = { L"*/*", nullptr }; Synchronized LMTBID; -std::pair Translate(const std::wstring& text, SentenceInfo sentenceInfo) +std::pair Translate(const std::wstring& text) { if (!apiKey->empty()) if (HttpRequest httpRequest{ diff --git a/extensions/googletranslate.cpp b/extensions/googletranslate.cpp index 943f08b..e8ee228 100644 --- a/extensions/googletranslate.cpp +++ b/extensions/googletranslate.cpp @@ -156,7 +156,7 @@ bool IsHash(const std::wstring& result) return result.size() == 32 && std::all_of(result.begin(), result.end(), [](char ch) { return (ch >= L'0' && ch <= L'9') || (ch >= L'a' && ch <= L'z'); }); } -std::pair Translate(const std::wstring& text, SentenceInfo) +std::pair Translate(const std::wstring& text) { if (!apiKey->empty()) if (HttpRequest httpRequest{ diff --git a/extensions/translatewrapper.cpp b/extensions/translatewrapper.cpp index 7eb3810..1e5ed6c 100644 --- a/extensions/translatewrapper.cpp +++ b/extensions/translatewrapper.cpp @@ -23,7 +23,7 @@ extern const char* GET_API_KEY_FROM; extern QStringList languages; extern bool translateSelectedOnly, rateLimitAll, rateLimitSelected, useCache; extern int tokenCount, tokenRestoreDelay, maxSentenceSize; -std::pair Translate(const std::wstring& text, SentenceInfo sentenceInfo); +std::pair Translate(const std::wstring& text); const char* LANGUAGE = u8"Language"; const std::string TRANSLATION_CACHE_FILE = FormatString("%s Cache.txt", TRANSLATION_PROVIDER); @@ -154,7 +154,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) if (auto it = translationCache->find(sentence); it != translationCache->end()) translation = it->second + L"\x200b"; // dumb hack to not try to translate if stored empty translation } if (translation.empty() && (!translateSelectedOnly || sentenceInfo["current select"])) - if (rateLimiter.Request() || !rateLimitAll || (!rateLimitSelected && sentenceInfo["current select"])) std::tie(cache, translation) = Translate(sentence, sentenceInfo); + if (rateLimiter.Request() || !rateLimitAll || (!rateLimitSelected && sentenceInfo["current select"])) std::tie(cache, translation) = Translate(sentence); else translation = TOO_MANY_TRANS_REQUESTS; if (cache) translationCache->try_emplace(sentence, translation); if (cache && translationCache->size() > savedSize + 50) SaveCache();