Thursday, January 4, 2018

Deepl - Command Line Language Translator Tool for Linux

DeepL is a command line tool which delivers text translation capabilities to your console. DeepL Translator is developed by German tech company DeepL. It is available to everyone, free of charge on www.DeepL.com.
DeppL translator is based on very advanced neural machine translation that delivers translations of unmatched quality. When users enter a text, DeepL’s artificial intelligence is able to capture even the slightest nuances and reproduce them in translation, unlike any other service.
We will install DeepL translator command line tool and will understand how it works in this article. The underlying logic of this command line tool is API calls it makes to their main website (www.deepl.com). So Whenever we try to translate something, It will send the request to the main website and get the results back. So, Your server or machine must have active internet connection for this tool to work. Translate Shell is another tool which does same function. Let's start with the installation.

Installation of Deepl Translator command line tool

Step 1: Before doing the installation DeepL, We need to install nodejs version >6.0. It prerequisite for DeepL translator tool. By default, Linux distributions don't come with node PPA configured. We will configure PPA first and then install nodejs 6.0. Ignore this step if you have nodejs already installed with 6.0 or higher version. Create a file /etc/apt/sources.list.d/nodesource.list and add content as shown below.
$ vi /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_6.x xenial main
deb-src https://deb.nodesource.com/node_6.x xenial main
Execute below step to install nodejs
$ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
$ apt-get update
$ apt-get install nodejs
Step 2: Install Yarn package dependency manager if it is not installed. Execute below commands to install yarn
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt-get update
$ sudo apt-get install yarn
Step 3: Finally, Execute below command to install Deepl translator on your machine.
$ yarn global add deepl-translator-cli
You can check installation status by checking the version of Deepl. Execute below command to check the version of Deepl installed.
$ deepl --version
1.0.1
That's it. We have successfully installed deepl translator. Now let's explore it.

Usage of Deepl Translator command line tool

Deepl translator supports below language at the time of writing this.
  • English (EN)
  • German (DE)
  • French (FR)
  • Spanish (ES)
  • Italian (IT)
  • Dutch (NL)
  • Polish (PL)
The neural networks are already training to master more languages like Mandarin, Japanese, and Russian.
Apart from translation, Deepl has capabilities to detect the input language too. So, Basically, Deepl works in two modes: one is translate and other is detect
  • Translation
    1. To translate the sentence or word use below syntax
$ deepl translate -t 'FR' "Hey, What's going on?"
Hé, qu'est-ce qui se passe?
Here, FR is ISO code for the french language, Deepl has given the output in the French language. Parameter Breakup of above translate command is shown below.
deepl translate -t '${TARGET_LANGUAGE_ISO_CODE}' '${INPUT STRING}'
  • Detection
    1. You can detect the language of specific sentence as show below using deepl translator.
$ deepl detect "Batman può essere chiunque"
Italian (IT)
Here, Deepl has detected the input sentence as italian. Parameter Breakup of above detect command is shown below.
deepl detect '${INPUT STRING}'
You can execute below command to get help from command line
$ deepl -help
Source: linoxide.com