I would like to translate words from English to Language X trough terminal
If it is possible, what kind of dictionaries there are?
Is it possible to use online services like webxicon.org trough terminal?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You can install
dictd server and use Freedict Dictionary database for word translations.
sudo apt-get install dictd
Install translation database. eg. dict-freedict-eng-fra for English to French translation, dict-freedict-eng-spa for English to Spanish translation.
sudo apt-get install dict-freedict-eng-fra sudo apt-get install dict-freedict-eng-spa
View list of databases:
Use a particular database eg. for English to Spanish translation:
dict -d fd-eng-spa "how are you?"
sudo apt-get install libtranslate-bin
eg. using online google translate engine:
echo "what are you doing" | translate-bin -s google -f en -t fr
Installing English dictionary databeses (gcide, wn, devil):
sudo apt-get install dict-gcide sudo apt-get install dict-wn sudo apt-get install dict-devil
Installing English Thesaurus database (moby-thesaurus):
sudo apt-get install dict-moby-thesaurus
Using a particular database (eg. WordNet - wn):
dict -d wn "dictionary"
Not specifying a dict-database will output definitions/translations/thesaurus from all available databases. eg.
Translate Shell (ex Google Translate CLI) is a tool that lets you use translate text from the command line using Google Translate.
$ wget git.io/trans $ chmod +x ./trans
sudo apt install translate-shell
$ git clone https://github.com/soimort/translate-shell $ cd translate-shell/ $ make $ [sudo] make install
trans en:de "The quick brown fox jumps over the lazy dog" # Translate to German (de) trans es: "Igualdad, fraternidad y libertad" # From Spanish to your `locale` trans :fr "Igualdad, fraternidad y libertad" # From your `locale` to French trans -b :fr "Igualdad, fraternidad y libertad" # Same but `-brief`
As a dictionary: Google Translate can be used as a dictionary when lang from==to or -d parameter is used
trans -d fr: mot
Additional information and some examples can be found in the official site
Depending on the language you want, check out Apertium for offline machine translation through the terminal. It seems to focus mostly on Romance languages (ES, FR, PT, CAT, OCC..), but looks like they are slowly adding various new languages.
For Spanish you would install:
sudo apt install apertium apertium-en-es echo "Hola Mundo." | apertium -a es-en > Hello world.
It's terminal based but there's also a basic GUI:
The version in the repos is older, if you want a newer version follow the install instructions.
I wrote a simple command-line translator base on google translate using Python.
The code: The python code is less than 100 lines, and I also wrote an installer script, and provide a config file so that could set your default preferred language.
It's under MIT license.
Pre-requisites: Python2.x on Linux, is all it needs, it don't support python3 yet, I might fix this later.
Have a look at sdcv based answer here (It also has "Xlanguage" to "Ylanguage" dictionaries):
Should also check surfraw. Once you install, you may get meaning of a word through
sr webster difficultWord. One way to translate will be through
sr google difficultword in hindi.There will probably be other options for translation as well.
I have written a simple command-line translator based on text files. It also reproduces an audio file if it exists. I already have a database of audio files, and if I don't find them, then I download them from a google database.
Argos Translate translates entire sentences from the terminal completely offline
pip -m pip install --user argostranslate
This downloads about 600 MB.
Download the models of interest from: https://drive.google.com/drive/folders/11wxM3Ze7NCgOk_tdtRjwet10DmtvFu3i Each model is unidirectional (i.e. e.g. either English to Chinese or Chinese to english) and about 80MB in size.
Open the GUI and install the downloaded models (TODO could not find CLI way)
Then you go "Manage Packages" on the menu, and select the downloaded file.
Once that is done, e.g. with the Chinese to English package, I can now do:
argos-translate-cli --from-lang zh --to-lang en '什么意思？'
and the output is:
What is meant?
which is semi-reasonable. I'd likely translate it as "What do you mean?".
The GUI is also convenient, as it is a bit nicer to paste stuff from the web into the GUI rather than the terminal:
Case Study: Xin Yue letter
I tried to paste the text into a file and then:
argos-translate-cli --from-lang zh --to-lang en $(cat input.txt)
but it didn't work very well. They don't seem to have a method to take input from a file currently, but Command Line is marked as "Beta", so give them some slack.
So the translation below is from the GUI. I fixed the formatting a little bit, but the text is unchanged.
Here, I formally put forward the following claims to the Foreign Language Institute of the University of Beijing:
- The Foreign Language Institute of the University of Beijing should make a public written statement of the regulatory framework under which I have imposed pressure on parents, entered the house and asked me to remove the information on the application for disclosure of information, and to make clear that violations of the law are committed and to take measures to avoid the recurrence of such incidents.
- The Foreign Language Institute of the University of Beijing should immediately stop all pressure on my family, formally tunnelling and clarifying the facts to the mother who has been threatened and helping to restore the family tensions that have resulted from the events.
- The Foreign Language Institute of the University of Beijing must publicly and in writing ensure that the matter does not have an impact on his graduation and will not continue to interfere with the process of writing my paper on the matter.
- The Foreign Language Institute of the University of Beijing is responsible for eliminating any other negative impact of this matter on his own education, future employment and family.
- The Beijing University College of Foreign Languages should provide a clear written response to the above claims and give a voice to all those concerned.
I will retain all the rights to further pursue the responsibility of the individuals and units concerned through legal means, including, but not limited to, reporting to the Beijing University and the superior authorities of serious violations of the discipline of foreign languages.
University of Beijing Foreign Language College, 14th class Bachelor
Manual (TODO confirm) translation:
Hereby I formally request the following from the School of Foreign Languages of Peking University:
- The School of Foreign Languages of Peking University should formally and publicly state the regulations, in accordance to which they pressured my parent without my knowledge, abruptly interviewed me in my dorm 1am in the morning and asked me to delete information related to the FOI request. Specify the illicit practices and put forward actions to prevent this from happening again.
- The School of Foreign Languages of Peking University should immediately stop any action of pressuring my families, formally apologize and clarify the facts to my frightened mother, and help to repair the family relationship intensified by this incident
- The School of Foreign Languages of Peking University must make a formal promise that this incident will not affect my graduation and will not disturb my Thesis preparation in the future.
- The School of Foreign Languages of Peking University is responsible to eliminate all other negative effects to my study, future employment and family, caused by this incident.
- The School of Foreign Languages of Peking University should publicly give a written response to the above appeals, as an explanation to those who are concerned about this matter.
I reserve the right to pursue legal actions against related individuals and organizations, including, but not limited to, reporting to the Peking University and superior administrations the severe violation of the Code of Conducts made by the School of Foreign Languages.
Undergraduate student Yue Xin, Class 2018 at the School of Foreign Languages of Peking University
Here, I formally make the following demands to the School of Foreign Languages of Peking University:
- The School of Foreign Languages of Peking University should publicly explain in writing that it has gone beyond me to pressure my parents, went to the dormitory to interview me in the early morning, and asked me to delete the relevant information related to the information disclosure application. The rules and regulations shall be clarified. Take measures to prevent such incidents from happening again.
- The School of Foreign Languages of Peking University should immediately stop all acts of pressure on my family, formally apologize and clarify the facts to my mother who has been frightened, and help repair the family tension caused by the incident.
- The School of Foreign Languages of Peking University must publicly ensure that this matter will not affect my graduation, and will not continue to interfere with my thesis writing process.
- The School of Foreign Languages at Peking University is responsible for eliminating all other adverse effects of this incident on my studies, future employment and family members.
- The School of Foreign Languages of Peking University should clearly respond in written form to the appeal request and give everyone who is concerned about this matter.
I will reserve all rights to further pursue the responsibilities of relevant individuals and units through legal means, including but not limited to reporting serious violations of school discipline by the School of Foreign Languages to Peking University and higher authorities.
Yue Xin, a 14-level undergraduate student, Peking University School of Foreign Languages
So we see that the Google Translate one is a bit better still. But there's promise in this project anyways!
Tested on Ubuntu 20.10, argostranslate==1.0.6.