lorniu / go-translate

Translator on Emacs. Supports multiple engines such as Google, Bing, deepL, ChatGPT, StarDict, Youdao and so on.
GNU General Public License v3.0
274 stars 37 forks source link

How to switch translator direction quickly? #71

Closed ShuguangSun closed 1 month ago

ShuguangSun commented 3 months ago

I have set the translator from en to zh as default as (gt-taker :langs '(en zh) :text 'word :pick 'paragraph :prompt t). How could I swtich it from zh to en quickly? Do I need to set another translator?

lorniu commented 3 months ago

If you config as '(zh en), it means that translate zh->en or en->zh, it will judge whether current text is zh or en, then auto choose the proper one.

If there is any issue in your translation, for example, it choose a wrong zh->en or en->zh, maybe there is a wrong logic in the code, please report.

artelse commented 1 month ago

I have following configuration and if I understand correctly, gt should pick the right direction of translation. However, it doesn't recognise the word as Dutch (nl) and outputs untranslated word.

(use-package go-translate
    :config
    (setq gt-default-translator
                (gt-translator
                 :taker   (gt-taker :prompt t :langs '(en nl) :text 'word :pick 'paragraph)
                 :engines (list (gt-bing-engine) (gt-google-engine))
                 :render  (gt-buffer-render)))
    )

P.S.: Is it possible to have it prompt for different configs like ts1, ts2, etc from the examples?

lorniu commented 1 month ago

I don't know the different between en and nl, and no logic existed to distinguish them.

You can read the doc or code of gt-lang-rules ( M-x describe-variable gt-lang-rules) for more details, and add the logic for nl if possible.

It's not an easy thing to determine the language, if failed to config the taker to distinguish en and nl, you can also use C-n or C-p to correct the direction in the prompt minibuffer.

artelse commented 1 month ago

Thanks for the explanation! Nice it remembers the translate direction.