This tutorial shows how to easily translate words from English into other languages on a Linux terminal. It also shows how to specify source language or more than a single destination language on the Linux terminal, how to identify languages without carrying out the translation process, how to identify languages from the terminal among more useful techniques to deal with languages.

For this tutorial the software used is Translate Shell, previously known as Google Translate CLI.

Translate Shell allows you to use Google Translate, Bing Translator, Yandex Translator and Apertium from the command line, while including all translation engines mentioned above Google is the default one.

Before downloading Translate Shell you need to get the gawk package by running:

Translate words from English into other language on Linux Terminal Translations

Once installed download Translate Shell using wget by running:

Note: on Debian and based Linux distributions you can install wget by running apt install wget.

Translate words from English into other language on Linux Terminal Translations

Once downloaded give Translate Shell execution rights by running:

Translate words from English into other language on Linux Terminal Translations

Lets try by translating a single word from Italian (to English since English is the default destination language). To translate the word pinguino run:

Translate a single word on Linux terminal:

Translate words from English into other language on Linux Terminal Translations

Note: using quotation marks is optional for single words and mandatory for sentences.

As you can see Translate Shell detected the source language as Italian and translated it to English despite the destination language wasn’t specified.

Now let’s translate the same word from English to Spanish. To specify a destination language use “:” followed by the destination language as in the example below:

Translate words from English into other language on Linux Terminal Translations

As you can see, Translate Shell translated it properly.

Translate more than a single word on Linux terminal:

Now let’s translate more than a single word, the following example shows the “Linux hint” translation, note for more than a single word quotation marks are mandatory.

# ./trans :es ‘Linux hint’

Translate words from English into other language on Linux Terminal Translations

Translate words from English into several other languages on Linux terminal:

Translate Shell also allows you to translate to different destination languages, the following example shows how to translate the sentence “At LinuxHint we seek the best content quality for readers” to Spanish and Chinese simultaneously by just separating language codes with a symbol:

# ./trans :es zh ‘At LinuxHint we seek the best content quality for readers’

Translate words from English into other language on Linux Terminal Translations

Specify the source language when translating words into other language on Linux terminal:

Sometimes translators fail to auto detect the source language, Translate Shells supports source language specification by placing the source language code before colon:

# ./trans zh: ‘在LinuxHint,我们为读者寻求最佳的内容质量’

Translate words from English into other language on Linux Terminal Translations

Specify both source and destination languages when translating on LInux terminal:

Of course you can specify both source and destination languages:

# ./trans zh:es ‘在LinuxHint,我们为读者寻求最佳的内容质量’

Translate words from English into other language on Linux Terminal Translations

Detect languages on Linux Terminal using Translate Shell:

You can use Translate Shell also to detect languages only, without proceeding with translation, obtaining additional information on the detected language by adding the -id flag as shown in the example below:

# ./trans -id “我们为读者寻求最佳的内容质量”

Translate words from English into other language on Linux Terminal Translations

Translate files from English into other language on Linux terminal:

Translate Shell also allows you to translate files. Using nano or any text editor you want create a text file with content on any language you want to translate to test Translate Shell.

# nano linuxhint-translation

Translate words from English into other language on Linux Terminal Translations

Then press CTRL X to save and exit

Translate words from English into other language on Linux Terminal Translations

To translate the content to Spanish use the syntax shown below adding file:// as content source to translate:

# ./trans :es file://linuxhint-translation

Translate words from English into other language on Linux Terminal Translations

Translate websites into other language on Linux terminal:

With Translate Shell it is possible to translate websites too using the syntax shown below to translate linuxhint.com.

# ./trans :es https://linuxhint.com

Translate words from English into other language on Linux Terminal Translations

As you can see Translate Shell returned a URL with a version of LinuxHint in Spanish:

https://translate.google.com/translate?hl=en&sl=auto&tl=es&u=https://linuxhint.com

Translate words from English into other language on Linux Terminal Translations

Translate words into other language on Linux terminal with interactive mode:

Translate Shell also offers an interactive mode, the following example shows how to launch the interactive mode to translate content from Spanish to English:

Translate words from English into other language on Linux Terminal Translations

Using Translate Shell as dictionary:

Translate Shells can be also used as dictionary if the option -d is implemented, the following example shows Translate Shells being used as dictionary for the word “encrypt”:

Translate words from English into other language on Linux Terminal Translations

Play sound to include spoken translation in the output:

To end this tutorial lets add sound to hear translations, to achieve it you need to install a terminal media player such as mplayer, on Debian and based Linux distributions run:

Play sound to include spoken translation in the output:

Translate words from English into other language on Linux Terminal Translations

Once installed, use the option -p to add sound to the output, the following example shows how to translate from Chinese to Spanish including the spoken translation:

Translate words from English into other language on Linux Terminal Translations

I hope you found this tutorial on how to translate words from English into other language on Linux terminal useful. Keep following LinuxHint for more tips and updates on Linux and networking.

About the author

Translate words from English into other language on Linux Terminal Translations

Ivan Vanney

Ivan Vanney has over 2 years as writer for LinuxHint, he is co-founder of the freelance services marketplace GIGopen.com where he works as a sysadmin.