Compare commits

...

3 Commits

8 changed files with 1 additions and 30 deletions

View File

@ -194,7 +194,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = false, useRateLimiter = true, rateLimitSelected = false, useCache = true, useFilter = true;
int tokenCount = 30, rateLimitTimespan = 60000, maxSentenceSize = 1000;
std::wstring dontTranslateIfMatch = L"";
std::pair<bool, std::wstring> Translate(const std::wstring& text, TranslationParam tlp)
{

View File

@ -105,7 +105,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = true, useRateLimiter = true, rateLimitSelected = true, useCache = true, useFilter = true;
int tokenCount = 10, rateLimitTimespan = 60000, maxSentenceSize = 1000;
std::wstring dontTranslateIfMatch = L"";
enum KeyType { CAT, REST };
int keyType = REST;

View File

@ -115,7 +115,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = true, useRateLimiter = true, rateLimitSelected = false, useCache = true, useFilter = true;
int tokenCount = 30, rateLimitTimespan = 60000, maxSentenceSize = 2500;
std::wstring dontTranslateIfMatch = L"";
BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{

View File

@ -48,7 +48,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = true, useRateLimiter = true, rateLimitSelected = false, useCache = true, useFilter = true;
int tokenCount = 30, rateLimitTimespan = 60000, maxSentenceSize = 2500;
std::wstring dontTranslateIfMatch = L"";
BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{

View File

@ -115,7 +115,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = true, useRateLimiter = true, rateLimitSelected = false, useCache = true, useFilter = true;
int tokenCount = 30, rateLimitTimespan = 60000, maxSentenceSize = 2500;
std::wstring dontTranslateIfMatch = L"";
BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{

View File

@ -234,7 +234,6 @@ extern const std::unordered_map<std::wstring, std::wstring> codes
bool translateSelectedOnly = false, useRateLimiter = true, rateLimitSelected = false, useCache = true, useFilter = true;
int tokenCount = 30, rateLimitTimespan = 60000, maxSentenceSize = 1000;
std::wstring dontTranslateIfMatch = L"";
std::pair<bool, std::wstring> Translate(const std::wstring& text, TranslationParam tlp)
{

View File

@ -17,7 +17,6 @@ extern const char* FILTER_GARBAGE;
extern const char* MAX_TRANSLATIONS_IN_TIMESPAN;
extern const char* TIMESPAN;
extern const char* MAX_SENTENCE_SIZE;
extern const char* DONT_TRANSLATE_IF_MATCH;
extern const char* API_KEY;
extern const wchar_t* SENTENCE_TOO_LARGE_TO_TRANS;
extern const wchar_t* TRANSLATION_ERROR;
@ -28,7 +27,6 @@ extern const char* GET_API_KEY_FROM;
extern const QStringList languagesTo, languagesFrom;
extern bool translateSelectedOnly, useRateLimiter, rateLimitSelected, useCache, useFilter;
extern int tokenCount, rateLimitTimespan, maxSentenceSize;
extern std::wstring dontTranslateIfMatch;
std::pair<bool, std::wstring> Translate(const std::wstring& text, TranslationParam tlp);
QFormLayout* display;
@ -120,14 +118,6 @@ public:
display->addRow(label, spinBox);
connect(spinBox, qOverload<int>(&QSpinBox::valueChanged), [label, &value](int newValue) { settings.setValue(label, value = newValue); });
}
auto matchEdit = new QLineEdit(settings.value(DONT_TRANSLATE_IF_MATCH).toString(), this);
dontTranslateIfMatch = S(matchEdit->text());
QObject::connect(matchEdit, &QLineEdit::textChanged, [](QString match) { settings.setValue(DONT_TRANSLATE_IF_MATCH, S(dontTranslateIfMatch = S(match))); });
auto matchLabel = new QLabel(QString("%1 (<a href=\"https://regexr.com/\">regex</a>)").arg(DONT_TRANSLATE_IF_MATCH), this);
matchLabel->setOpenExternalLinks(true);
display->addRow(matchLabel, matchEdit);
if (GET_API_KEY_FROM)
{
auto keyEdit = new QLineEdit(settings.value(API_KEY).toString(), this);
@ -162,7 +152,7 @@ private:
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
if (sentenceInfo["text number"] == 0) return false;
if (sentenceInfo["text number"] == 0 || sentence.size() > maxSentenceSize) return false;
static class
{
@ -192,17 +182,6 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
sentence.erase(std::remove_if(sentence.begin(), sentence.end(), [](wchar_t ch) { return ch < ' ' && ch != '\n'; }), sentence.end());
}
if (sentence.empty()) return true;
try
{
if (!dontTranslateIfMatch.empty() && std::regex_match(sentence, std::wregex(dontTranslateIfMatch)))
{
sentence += L"\x200b \n" + sentence;
return true;
}
} catch (...) {}
if (sentence.size() > maxSentenceSize) translation = SENTENCE_TOO_LARGE_TO_TRANS;
if (useCache)
{
auto translationCache = ::translationCache.Acquire();

View File

@ -160,7 +160,6 @@ const wchar_t* ERROR_START_CHROME = L"failed to start Chrome or to connect to it
const char* EXTRA_WINDOW_INFO = u8R"(Right click to change settings
Click and drag on window edges to move, or the bottom right corner to resize)";
const char* MAX_SENTENCE_SIZE = u8"Max sentence size";
const char* DONT_TRANSLATE_IF_MATCH = u8"Don't translate if match full";
const char* TOPMOST = u8"Always on top";
const char* DICTIONARY = u8"Dictionary";
const char* DICTIONARY_INSTRUCTIONS = u8R"(This file is used only for the "Dictionary" feature of the Extra Window extension.
@ -922,7 +921,6 @@ esempio: Textractor -p4466 -p"My Game.exe" sta tentando di inniettare i processi
EXTRA_WINDOW_INFO = u8R"(Tasto destro per cambiare le impostazioni
Clicca e trascina i bordi della finestra per muoverla, oppure nell'angolo in basso a destra per ridimensionare)";
MAX_SENTENCE_SIZE = u8"Dimensione massima sentenza";
DONT_TRANSLATE_IF_MATCH = u8"Non traduce se corrisponde completamente";
TOPMOST = u8"Sempre in primo piano";
DICTIONARY = u8"Dizionario";
DICTIONARY_INSTRUCTIONS = u8R"(Questo file è utilizzato solo per la funzione "Dizionario" dell'estenzione Extra Window.