google-translate icon indicating copy to clipboard operation
google-translate copied to clipboard

add exclusion with regexp?

Open magichowl opened this issue 11 years ago • 10 comments

Ass the title, I don't want to translate text enclosed with $ or other marks, can I achieve that?

magichowl avatar Jul 03 '14 12:07 magichowl

Please provide more details. Explain exactly steps which you performs and expected result. Why you need that functionality? At least show an example which will allow me better understand your request

atykhonov avatar Jul 03 '14 12:07 atykhonov

For example, you want to be able to select all text in the buffer and translate it but wants google-translate to skip parts of text (lines, paragraphs) which enclosed with $

atykhonov avatar Jul 03 '14 12:07 atykhonov

It is hard for me to understand your needs thus understand required functionality so please provide a little bit more info

atykhonov avatar Jul 03 '14 13:07 atykhonov

in latex mode, $ $ is the inline enviroment for math formulas,

* in $*$ may contain math command, say, $\mathbf{a}$ (a), $\alpha$ so I want to skip this part for conversion.

It would be a great convenience because this feature may be needed in many situations.

think about converting html source code,

is a beginning tag for an environment, of course we don't want to convert the word "body"

magichowl avatar Jul 03 '14 13:07 magichowl

Thanks for explanation! Now it is much more clearer! I'm not sure for now how exactly that feature could be implemented and integrated into the google-translate but let me think and see what can be done.

atykhonov avatar Jul 03 '14 14:07 atykhonov

I'll be working on this request as soon as I'll finish #15 and #16

Stay tuned!

atykhonov avatar Jul 03 '14 15:07 atykhonov

I'm not familiar with emacs lisp. But I have some idea. Can it be implemented in the following way?

  1. ch = peek a character in the block of text for conversion,
  2.   if (_ch_ is not in _symbols_)
    
  3.         _str_ += _ch_ 
    
  4.   else 
    
  5.         _strDes_ = translate  _str_
    
  6.         _begin_ = _ch_
            {
    
  7.               _strDes_  += ch
             }
    
  8.          while (peek != begin)
    

magichowl avatar Jul 03 '14 15:07 magichowl

Well, ok, there is no any issue which relates to the algorithm. I'm thinking about the best way to integrate it with google-translate... How the symbols (patterns) will be defined how they will be used etc. Probably it would be good to provide patterns for different modes... May be not. Not sure for now. It needs some time to rethink every aspect of that issue and implement it.

atykhonov avatar Jul 03 '14 15:07 atykhonov

Yes, it seems not as easy as I was thought. there are many patterns I don't want to convert, says $$ ( double dollar environment $$ * $$), [ * ], \begin{equation} * \end{equation}, and so on

This issue tortured me a lot recently. I would be of great appreciate if you don't mind providing a elementary version for just a single character as the symbols.

magichowl avatar Jul 03 '14 15:07 magichowl

Yes, it seems not as easy as I was thought.

Yes, that's right!

I would be of great appreciate if you don't mind providing a elementary version for just a single character as the symbols.

Ok! You provided me the example (with html, and now other examples) so for now I don't think only about symbols, but about patterns... ... Anyway after this feature will be implemented it would be great to hear from you feedback: is it good for you or not, what exactly is not good and how it could be improved. I don't like implement it just for the sake of itself. It needs to be useful. And as you are expecting that feature it should be useful particularly for you.

atykhonov avatar Jul 03 '14 15:07 atykhonov