How To Use Google Translate From Commandline In Linux
Howdy fellow Linux users! I have just stumbled upon this cool utility, and I couldn’t resist myself to share it with you all. Meet, Translate Shell (formerly known as Google Translate CLI), a command-line translator powered by popular translation engines such as Google Translate (default), Bing Translator, Yandex.Translate and Apertium etc. It allows you to access one of these translation engines from your terminal. Google Translate is my first preferred source to translate English to Tamil and vice versa. Since I am not a native English speaker, I mostly depend on Google Translate for both my professional and personal use. Translate Shell utility is very useful handy when it comes to translate words from English to your native language and vice versa from Terminal. It will work on most modern operating systems, including GNU/Linux, FreeBSD, MS Windows, and Mac OS X.
In this tutorial, we will be discussing how to translate a word, a sentence, or even a webpage from your preferred language to English and vice versa. Let’s get started!
Use Google Translate From Commandline In Linux using “Translate Shell”
Install Translate Shell
Translate Shell is available as self-contained executable file. Just download and make it as executable and start using it.
$ wget git.io/trans
$ chmod +x trans
Or, you can clone it from the git repository, compile and install it as shown below.
$ git clone https://github.com/soimort/translate-shell
$ cd translate-shell/
$ sudo make install
How to use Translate Shell
To translate a word, just type:
$ trans வணக்கம்
வணக்கம் (Vaṇakkam) Hello Translations of வணக்கம் [ தமிழ் -> English ] வணக்கம் Hello, Greetings, Good, Hi, Salute
As you see in the above output, I have translated a Tamil word “வணக்கம்” (Vanakkam), which is used to greet people, to English. Please note that if you have downloaded self-contained executable file, you need to run “./trans வணக்கம்” (without quotes, of course).
To translate a whole sentence at once, Just type ‘trans’ command followed by the sentence within quotes like below.
$ trans "எப்படி இருக்கீங்க?"
எப்படி இருக்கீங்க? (Eppaṭi irukkīṅka?) How are you? Translations of எப்படி இருக்கீங்க? [ தமிழ் -> English ] எப்படி இருக்கீங்க? How are you?
As you see in the above example, Translate Shell gives you the detailed translation of the given sentence.
To get the brief translation of the given sentence, type the sentence with -brief parameter as shown below.
$ trans -brief "எப்படி இருக்கீங்க?"
The sample output would be:
How are you?
This above command will just display the actual translation.
I want to translate a whole text file to English, is it possible? Yes you can.
Let us see the contents of text file
$ cat greet.txt
Here is what I have in the text file.
வணக்கம். எப்படி இருக்கீங்க?
To translate this text file, just type:
$ trans file:///home/sk/greet.txt
Hello. How are you?
Cool isn’t it?
As you noticed, all the translations that we did till now are from other languages (Tamil in my case) to English. If you want to change the target language, type :(colon) followed by specific language code.
Say for example, to translate a word to Hindi, just type:
$ trans :hi வணக்கம்
This command will translate the Tamil word “வணக்கம்” to Hindi language.
வணக்கம் (Vaṇakkam) नमस्ते (namaste) Translations of வணக்கம் [ தமிழ் -> हिन्दी ] வணக்கம் नमस्ते, करें Hello, नमस्कार, Hello
If you don’t know the language code, type:
$ trans -R
Just pick any language of your choice and translate the sentence instantly. You don’t need a web browser. Everything will be displayed right from your Terminal.
What about translating a website? That’s also possible.
$ trans https://www.ostechnix.com/
This command will open a new browser window and translate the website into English. Since the above website is already in English, It just displayed:
The page you have attempted to translate is already in English.
To translate ostechnix.com site to some other language, for example Hindi, just type:
$ trans :hi https://www.ostechnix.com/
That’s all for today. We know now all the important functions of Translate Shell. For more details, type:
$ trans -M
Note: Here M is capital letter.
Hope this help. Have you used Translate Shell already? Great! Let us know about your experience in the comment section below.
And, that’s all for now folks. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!