Translate Shell is a free and open source command line translation tool for Linux, macOS, BSD, Android and Windows. Translate queries using Google Translate, Bing Translator, Yandex Translator, and Apertium engine. Formerly known as the Google Translate CLI, this tool now uses four different sources to get its results. The default is Google Translate, but you can easily switch to another service. It’s a great tool for non-native command line users. By default, this tool will translate the specified word into English.
Install the translation shell on Ubuntu
The Translate Shell command line translation tool can be installed via the default Ubuntu package manager or directly downloaded.
Ubuntu Package Manage:
Open the terminal (ctrl + alt + t) app and run these commands. If necessary, enter the ubuntu user password.
sudo apt update
sudo apt install translate-shell
You can also install it from a self-contained executable and make it executable.
chmod +x ./trans
sudo mv trans /usr/local/bin/
Then move it to your $ PATH.
Google Translate from command line:
Run this command in your terminal to find the language code.
This helps you translate from one source language to another target language.
References: How to install ddgr DuckDuckGo Search on Ubuntu-Search DuckDuckGo from Linux Terminal
Here are some examples.
Note: By default, the translation shell translates all languages into English.
Translate Spanish to English
You will get the following output.
Enclose the entire statement in quotation marks.
trans "Hola como estas"
Translate content from file:
Translate to other than English:
You can specify the target language in the following ways -t
English to Dutch
trans -t nl Hello
English to Dutch, Czech, Greek
trans -t nl+cs+el Hello
Translate from a specific language
You can also specify the source language with -s
trans -s es Hola
The following command translates an English website into Spanish
trans -t es https://connectwww.com/
Click the link on your device.
If you don’t know the language, you can also specify the language.
trans -id Hola
Run this command for more information on using the full conversion shell.
It’s a sequel.