After reading two articles on
zenity, I thought that it would be nice to try myself in it, but I could not find a suitable task for this, but I was already tired of building windows with buttons for the sake of interest. And so, for your information, my first non-useless bash script is provided using zenity.
I use firefox as a great addition to translating the text in the context menu called My-translator, it is lightweight, convenient and I like it. And the other day I wanted a similar feature and in my Linux, I have hands, head too, the choice fell on bash + zenity + wget + Yandex.Translate.
First of all, you need to find out if Yandex has api, you haven’t found such a section on the site (maybe you’ve been looking bad?), Google showed links to one
blog where there was an example of using api to translate using ajax. Using the hurl service, I quickly realized that I needed to pass three basic parameters: text, lang and srv. The text should contain our text, lang is the native language and the language for translation in the format “en-ru”, and the srv parameter indicates that we want to use the translation - “tr-text”. With this easy and understandable, we go further.
')
The script turned out to be small and effective, at least for me.
In bash it is not strong, but I can google.
In the 6th line, I used the xclip utility so that you can simply select the desired text and press the hot keys and the field will appear with the text already inserted in it, it is convenient how. Are there any other ways to make an http request with the bash script I do not know, but wget does an excellent job with this.
That's all, then we add hot keys to launch the script and you will be happy. I would be glad if someone will help.