soimort / translate-shell

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

Show target language on REPL mode #506

Closed Dominiquini closed 5 months ago

Dominiquini commented 7 months ago

The prompt shows the SOURCE language ("Italiano>"), but not the target language.

Config the prompt to show both the SOURCE and TARGET languages ("Italiano:English>")

Thanks

soimort commented 7 months ago

I don't remember if it's documented, but this can be easily done by setting your own theme file.

If you don't have a theme, create a new file such as ~/.translate-shell/my_prompt.trans with following content:

{
 :fmt-prompt "%s:%t> "
}

(%s for names of source languages, %t for names of target languages, %S for English names of source languages, %T for English names of target languages, etc.)

Then add this theme to your config file:

{
 :theme "my_prompt.trans"
}

If you already have a theme, then just change that ":fmt-prompt" value to the wanted prompt string.

Dominiquini commented 7 months ago

Thanks!

Just one thing I noticed here. If I change the source language to automatic (:pt), after having defined a source language, the prompt continues in the previously configured language! Is there any code to use automatic language detection?

Thanks.

soimort commented 7 months ago

The command to set the source language to automatic is

:set sl auto

Simply :pt will change only the target language to pt and leave the source language as is. Similarly, it: will change only the source language to it and leave the target language as is. This was the intended behavior, I think, as it enables you to change only the source or the target lang conveniently, without having to specify the full language pair.