Would you like to translate a text string between multiple languages using the terminal? Perhaps while browsing the internet you came across a message written in another language and you want to know what it means. Fortunately, Linux has several command line applications that you can use to convert words from one language to another.
This article explains two utilities, DeepL Translator and Translate Shell, which a user can use to translate strings into another language directly from the system terminal.
Using DeepL Translator
The DeepL Translator uses machine learning technology to translate text between languages. If you cannot find out the language of a text yourself, the DeepL Translator will automatically identify it for you. Your system must have an active internet connection to use the translator as it uses the DeepL API to translate text.
The DeepL Translator supports the following languages:
The Linux package for the DeepL Translator can be used free of charge. However, you can purchase a subscription if you plan to use the tool frequently. Although the plans and prices are different for each country, each country also has a free subscription for the users.
Install DeepL Translator
To run DeepL Translator on your Linux computer, you must first install the latest version of Node.js.
Now download and install the yarn package manager. With some Linux distributions, the process is a little different. In this guide we are going to discuss how to install Yarn on Debian and Fedora.
On Debian-based distributions like Ubuntu, download the Yarn GPG key with Curls.
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo add apt-key –
Add the Yarn Debian repository to your system's repository list.
echo "deb https://dl.yarnpkg.com/debian/ Stable Main" | sudo tee /etc/apt/sources.list.d/yarn.list
Update the repository list and install yarn with it SUITABLE.
sudo apt update
build in sudo apt yarn
For Fedora and other RPM-based distributions, you must first add the yarn repo to the repository list. The Node.js dependencies are automatically installed in Fedora, so you don't have to install them manually.
curl –silent –location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
You can either install yarn with it DNF or delicious. Enter one of the following commands in the terminal.
Insert sudo yum yarn
Insert sudo dnf yarn
After you've installed the Yarn Package Manager on your system, it's time to download the DeepL Translator Package. Enter the following to install DeepL Translator:
Add yarn globally deepl-translator-cli
You can verify that Yarn has successfully installed DeepL Translator on your system by checking the version information for the package.
Using the DeepL translator
Translating text with the DeepL Translator is easy. To translate a string into another language, specify the language code and string with the command.
deepl translate -t "DE" "Hello, how are you?"
As mentioned above, the DeepL Translator can recognize the language of the given text. Use the detect Option with the deepl Command.
deepl recognize "This is in English"
As with other Linux commands, you can use Pipe deepl with the standard output. For example:
echo "How are you" | deepl translate -t "DE"
If you can't figure out how to use the translator, you can check the help section using -H Flag. The developers have provided help pages for every option available in the utility.
deepl translate -h
recognize deepl -h
Use the translation shell utility
Translate Shell is one of the most widely used command line language translators on Linux. It was previously known as the Google Translate CLI. The power of Google Translate, Bing Translator, Apertium and Yandex Translate make it a reliable tool for translating text strings directly from the terminal.
To install Translate Shell on your Linux computer, download the executable and add it to your system's environment variables.
Assign executable permissions to the downloaded file.
sudo chmod + x ./trans
Add the executable file to the environment variables.
sudo mv ./trans / usr / local / bin
Using the translation shell
Translating text with Translate Shell is quite easy compared to the DeepL Translator. There are three output modes in the application: Standard, Interactive and Short.
In standard mode, the output contains information about the translation. In the short mode, however, only the translated text is displayed.
By default, the utility translates the text into English. To translate a string to English using the Translate Shell:
trans "This is in English"
The system displays the following output.
If you want to translate a string into a language other than English, you must use the language code. For example, to convert a string from English to Spanish:
trans: it "hello everyone"
Hola a todas
If Translate Shell cannot identify the language of the text, you can specify the language code with the command.
trans es: "Hola a todas"
Note that in the last two commands, the left side of the Colon ((::) Character stands for the source language and the right side stands for the target language.
To translate a single string into multiple languages, pass the appropriate language codes separated by plus ((+) Character.
trans: es + hi "Hello everyone"
The above command translates the given text into Spanish and Hindi.
You can transfer both the source and the target language.
trans es: hi "Hola a todas"
If you don't know the language of the string, you can use that -I would Flag with the default setting trans Command.
trans -id "Hola a todas"
Pass in the name of the file to translate complete files into another language.
trans en: es file: //document.txt
Use the -short Flag to switch to a simple output format.
trans-brief "This is in English"
This is in English
To use the interactive translation shell:
Trans shell letter
Now you can start typing your instructions and the system will translate the text in an interactive way.
Translating text on the Linux command line
Sometimes while surfing the Internet, you have come across text written in a language that you do not understand. While most browsers these days have automatic language translation features, they don't work well every time. In such situations it can be helpful to have a command line language translator.
You can also translate a web page using online tools. Various tools are available on the Internet with which you can translate any website into the language you want immediately.
The 7 best browser tools for translating websites
Almost half of the entire Internet is only accessible if you are fluent in multiple languages. What are the best tools for translation? These.
About the author
(51 articles published)
Deepesh is the junior editor for Linux at MUO. He has been writing informational content on the Internet for over 3 years. In his spare time he enjoys writing, listening to music and playing the guitar.
From Deepesh Sharma
Subscribe to our newsletter
Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!
One more step …!
Please confirm your email address in the email we just sent you.