Textractor icon indicating copy to clipboard operation
Textractor copied to clipboard

translatewrapper: regex lineedit doesn't translate sentence on a full match

Open Blu3train opened this issue 2 years ago • 2 comments

Added lineedit to tranlsator extensions with regex filter that doesn't send the sentence to the translator on a full match, but displays the text in the extra window. In this way you can create rules not to send untranslatable text to the translator.

Examples: 1 - For the Japanese source language. This rule does not send the sentence to the translator if at least one Japanese character is not present. (Rule copied from VN OCR. Thanks @leminhyen2) [\u0000-\u303f\u3100-\u33ff\u4dc0-\u4dff\ua000-\uf8ff\ufb00-\uff65\uffa0-\uffff]+

2 - For source language English, Italian and other Western languages. If the sentence doesn't contain at least one character of the alphabet (a-z), it does not send the sentence to the translator. [^a-zA-Z]+

Blu3train avatar May 24 '22 21:05 Blu3train

image

Blu3train avatar May 25 '22 15:05 Blu3train

~~I realized that the translators works on all threads. With this change only the selected thread is translated.~~

Blu3train avatar Jun 02 '22 13:06 Blu3train

(an observation) I understand that this change will only affect a perticaular translator, for example, if I have both deepl and google translators added, then if I configura this value for Deepl, then google will not be affected.

But If we want to apply a regex to all translators then we can use Regex Filter extension.

shoaibshakeel381 avatar Sep 18 '22 13:09 shoaibshakeel381

This filter is used to inhibit the call to the translator if there is no character of the source language in the characters, not to modify the sentences.

If you need to translate from Japanese, enter the regex of example 1 [\u0000-\u303f\u3100-\u33ff\u4dc0-\u4dff\ua000-\uf8ff\ufb00-\uff65\uffa0-\uffff]+ if the text does not contain any Japanese characters, the text is output as is without sending it to the translator, but is displayed as if it had been translated. This could be English-only text, such as exclamation characters only, such as "...!?!"

Blu3train avatar Sep 18 '22 13:09 Blu3train