soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
7k stars 393 forks source link

Ignore substring when matching regular expression #75

Open Turkish opened 9 years ago

Turkish commented 9 years ago
trans -b "Some long phrase containting  an %{injected_value} not to be translated " --ignore "REGULAR_EXPRESSION"

tell trans command to ignore a substring matching a regular expression

spifd commented 8 years ago

+1

JohnnyKing94 commented 7 years ago

+1 how long will it take furthermore?

JohnnyKing94 commented 7 years ago

This might help for google translate: https://cloud.google.com/translate/faq#technical_questions

Please do this

JohnnyKing94 commented 7 years ago

This is for Bing: https://msdn.microsoft.com/en-us/library/dn341982.aspx

rsvp commented 7 years ago

Exclusion list

Good idea... does upstream, for example, Google Translate, have special strings which always translate to themselves?

Q: How do I tell Google Translation API to NOT translate something?

A: You can use the following HTML tags:

        <span translate="no"> </span>
        <span class="notranslate"> </span>

    This functionality requires the source text to be submitted in HTML.

Then downstream, we could use have an exclusion list used to s/exclude1/SPECIAL1/ with respect to the input, then reverse the substitutions from the upstream output.

Exclude by regular expression(s)

Pre-filter the input, find matches to regex, then add them to a temporary exclusion list, apply exclusion list routine.

et2010 commented 7 years ago

Any updates on this?