tw man page

tw — translate words into different languages

Synopsis

tw [OPTIONS] [DICTIONARY] [TERM]

Example: tw en-es hello

Description

translate word is a command that translates words into different languages. translate word uses internal dictionaries, and contacts online to the Google Translation and the FreeTranslation engines.

Mandatory arguments for long options are mandatory for short options too.

-l, --list
list available dictionaries
-s, --shortcuts
list available dictionaries shortcuts
-x, --exact
try to perform an exact match
-y, --synonyms
try to perform a synonym triangulation
-p, --spelling
try to check the spelling grammar
-k, --speak
try to speak the text
-d, --disable-logging
disable logging of failure terms
-h, --help
show a help message
-v, --version
show the program version

Create ~/.tw directory to enable caching and logging (mkdir ~/.tw).

With no term, or when term is -, read standard input.

For straight synonyms, check mythes command.

Examples

Translate an english word to spanish using local dictionary
$ tw en-es hello
hola
Search your dictionaries
$ tw -l | grep en-es
share.en-es
cache.en-es
local.en-es
www.freetranslation.com.en-es
translate.google.com.en-es
List your shortcuts
$ tw -s
share = sh
cache = ca
local = lo
www.freetranslation.com = ft
translate.google.com = gt
Translate an english word to spanish using Google Translator
$ tw translate.google.com.en-es Hello
Hola
$ tw gt.en-es Hello
Hola
Language Helper (uses dict)
$ function lh { dict -d wn "$1"; echo; echo "Translation: $(tw en-es "$1")" }
$ lh mink
1 definition found

From WordNet (r) 3.0 (2006) [wn]:

  mink
      n 1: the expensive fur of a mink
      2: fur coat made from the soft lustrous fur of minks [syn:
	 {mink}, {mink coat}]
      3: slender-bodied semiaquatic mammal having partially webbed
	 feet; valued for its fur

Translation: visón
Select text in an xsession, and translate it with "control + t" (uses xbindkeys + xsel + xmessage/xdialog/gdialog/zenity/kdialog/...)
 ~/.xbindkeysrc
 	"term=$(xsel); [[ ! -z $term ]] && (translation=$(tw -d en-es "$term") || translation=$(tw gt.en-es "$term"); [[ -z $translation ]] && translation="Translation not found."; kdialog --title "Translate Word" --msgbox "$translation")"
 		control + t
 	"term=$(kdialog --title "Translate Word" --inputbox "Term:"); [[ ! -z $term ]] && (translation=$(tw -d en-es "$term") || translation=$(tw gt.en-es "$term"); [[ -z $translation ]] && translation="Translation not found."; kdialog --title "Translate Word" --msgbox "$translation")"
 		control + shift + t
$ xbindkeys
Local (offline) translation (so limited that it performs a non exact match search)
$ tw en-es fur
piel
fake fur : piel sintética
furuncle : furúnculo
Get offline cached online translation
$ mkdir ~/.tw
$ tw gt.en-es fur
piel
$ tw --list
***
***
cache.en-es
$ tw cache.en-es fur
piel
$ tw en-es fur
piel
Pronunciation Helper (uses festival)
$ function ph { tw en-es "$1"; echo "$1" | festival --tts; }
$ ph mink
visón 
***
Don't use a lot of online resources
$ function twc { tw -d en-es "$1" 2> /dev/null || tw gt.en-es "$1"; }
Pipe in
$ echo "hello" | tw en-es -
hola
Exact match
$ tw en-es hi
hola
***hi :
*hi** :
**hi* :
hi*** :
$ tw -x en-es hi
hola
Synonyms
$ tw en-es awesome
tw: term not found (maybe not connected) logged /home/$user/.tw/en-es.twdf
Try `tw --help' for more information.
$ tw -y en-es awesome
asombroso
impresionante
$ mythes en awesome
amazing
awe-inspiring
awful
awing
impressive
$ mythes es impresionante
alucinante
asombroso
aterrador
catastrófico
dantesco
emocionante
escalofriante
espantoso
espeluznante
estremecedor
horrible
horripilante
increíble
infernal
inquietante
pasmoso
pavoroso
sensacional
sobrecogedor
sorprendente
terrible
tremendo
Speak
$ tw -x -k en-es home
hogar
((( home ))) (voice: en)
((( hogar ))) (voice: es)

Notes

To add dictionaries just place them in ${prefix}/share/tw/lang1-lang2.twd ( tw dictionary , format is term1 : translation2 ). To add new engines just implement ${prefix}/share/tw/tw_*.sh (see actual implementations for examples). In both cases, integration is automated.

Caches are located in ~/.tw/*.twdc ( tw dictionary cache ), and handled transparently. Logs of untranslated terms are located in ~/.tw/*.twdf ( tw dictionary failure ), specially you could check this files when going online.

If you use the online engines respect their terms of use. Consider contributing local dictionaries or improvements to this project.

Author

Written by Juan Manuel Borges Caño.

Homepage

tw (translate word) home page <http://code.google.com/p/translateword>.

Reporting Bugs

Report bugs to <juanmabcmail@gmail.com>.

Info

April 2016 tw 0.9.16 User Commands