Skip to content

Conversation

Blu3train
Copy link
Contributor

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
Copy link
Contributor Author

image

@Blu3train
Copy link
Contributor Author

Blu3train commented Jun 2, 2022

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

@shoaibshakeel381
Copy link

shoaibshakeel381 commented Sep 18, 2022

(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.

@Blu3train
Copy link
Contributor Author

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 "...!?!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants