Feature request: auto select target language
I am a Russian, and I often want to translate some English word into Russian, so I use trans :ru, I also often want to translate from Russian into English and I want to do it both with one unique command, and it'd be super cool if there was an option like if the source language is English then translate to Russian and vice versa. Something like trans :ru|en. I couldn't find this option in the readme, please point me in the right direction if it's already implemented, I guess if language identification is already implemented it's not difficult to do what i want
Just made it
#!/bin/bash
source_text=$(xsel -o)
lang='ru'
if trans -id "$source_text" | grep -q 'Русский'
then
lang='en'
fi
translation=$(trans -brief :$lang "$source_text")
# Put translation to clipboard
echo -n "$translation" | xclip -selection clipboard
# Show notify with source text and translation
notify-send -t 2500 "$source_text" "$translation"
This could be a useful feature, but :ru|en would not be valid (unless surrounded by quotes) since vertical bars are used to indicate pipes in most Unix shells.
Please leave a comment if anyone has any suggestion on the proper syntax.
I have finally come up with an idea (it's not that I've been thinking about it the whole time though :D). I just looked at Configure page in the wiki, and there's this
What if one could enter two languages into :hl option? Would that be easy to implement or even possible?
P.S. Thank you for keeping this issue open!
:hl is intended only for selecting the "home language" (language used in displaying prompt messages); it should not be messed with the semantics of :tl, which specifies the actual target language(s) to translate to.
My take is to enable some user-definable a posteriori rules for specifying the relation between identified language / target languages. This would be certainly implementable, but nontrivial in any way.
:tl (match il
"en" => "ru"
"ru" => "eo"
"eo" => "tlh"
_ => ["de" "fr"])