soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
6.98k stars 394 forks source link

Document searched words locally #230

Open pwyq opened 6 years ago

pwyq commented 6 years ago

This is a very cool and useful tool!!

I have been using this tool for a while, and from time to time, I wish there is a mechanism that can automatically detect a newly-searched word and append it to a local text file. Such that, we would have a personalized glossary book after a period of time (which I believe it would be a great feature to help users learning new words).

I am wondering if this feature is already in future development plan of the translate-shell? Or is it possible to implement? If this feature is feasible, I would like to contribute :).

soimort commented 6 years ago

Glossary would be a nice thing to have.

Appending words to a local text file can be trivially implemented. But is there anything else you would like to achieve with trans, like showing a warning while looking up a previously searched word or quizzing the user about a random word? Or just having an incremental text file is sufficient?

pwyq commented 6 years ago

Hi, :) Showing a warning is a nice idea. To build on top of that, can we count the number of times of each searched word, and then sort all words based on search frequency?

aeosynth commented 6 years ago

I would like the word plus its definition saved to a file, then I can trivially make flashcards out of that. I don't think trans itself should be a flashcard app.

miranche commented 5 years ago

Upvoting this enhancement, also for the purpose of making flashcards.

pwyq commented 4 years ago

A trivial way to save to a text file:

(I put it in my ~/.bash_profile, one may also put in ~/.bashrc)

function tran() {
    vocab_path='/absolute/path/to/your/file'
    echo "================================" >> $vocab_path
    # :zh = translate to Chinese; sed removes special characters
    trans :zh $1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | tee -a $vocab_path
    echo -e "\n" >> $vocab_path
}

Then you can just call $ tran new-word to see the translation and also saves to a file.