How To Use Google Translate From Commandline In Linux
I have stumbled upon this cool utility today, and I couldn’t resist myself to share this to our users. Meet, Translate Shell (formerly known as Google Translate CLI) is 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 depend on Google Translate a lot for both my professional and personal work. Translate Shell utility is very useful handy when it comes to translate words from English to your native language and vice versa from Terminal. Translate Shell 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 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.
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
sudo make install
How to use Translate Shell
To translate a word, just type:
வணக்கம் (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
Here is what I have in the text file.
வணக்கம். எப்படி இருக்கீங்க?
To translate this text file, just type:
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:
Just pick any language of your choice and translate the sentence instantly. You don’t need a web browser. Everything will displayed in the Terminal.
What about translating a website? That’s also possible.
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:
Note: Use capital M.
Hope this help. Have you used Translate Shell already? Great! Let us know about your experience in the comment section below.
Thanks for stopping by!
How can I benefit from this blog:
- Subscribe to our Email Newsletter : Sign Up Now
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!