twandgtw (tw)

En bref

The twandgtw project allows you to get language translations directly from the Linux command line using either local dictionaries or online services.

Pour traduire en utilisant les services google en ligne de commande; en jouant un peu on faire des traductions complexes, p.ex. français → anglais → russe (cf infra)

je crois que ça marche que sur linux, argument de plus pour y passer!

Liens

Install notes

install on an ubuntu (Feisty): (required if you run with google: curl, is necessary do a litte apt-get install curl)

sudo su
alien tw-0.1.2-0.1.fc9.i386.rpm
dpkg -i tw_0.1.2-1.1_i386.deb

usage:

tw en-es hello
hello : hola

$ tw translate.google.com.en-fr  'that looks like a tasty cake'
Qui ressemble à un gâteau savoureux
$ tw translate.google.com.en-ru  'that looks like a tasty cake'
Похоже, что вкусный торт

Bugs on ubuntu > Feisty

thanks to Samuel B

tw dans /usr/local/bin/tw .
Quand j'édite ce fichier, à la ligne 133, j'ai 2 instructions qui 
comportent des fautes :
2x : "links -dump" seuls ... Sans urls.

Après essais, j'ai transformé cette ligne :

curl -s -A "Mozilla/5.0" -d "hl=en" -d "ie=UTF8" -d "text=${TW_TERM}" -d 
"langpair=${TW_LANGUAGE}" http://translate.google.com/translate_t | grep 
"gtrans" | gawk -F"gtrans" '{print $2}' | cut -d'"' -f2 | links -dump | 
links -dump | sed -e 's/^[[:space:]]*//'

en

curl -s -A "Mozilla/5.0" -d "hl=en" -d "ie=UTF8" -d "text=${TW_TERM}" -d 
"langpair=${TW_LANGUAGE}" http://translate.google.com/translate_t | grep 
"gtrans" | gawk -F"gtrans" '{print $2}' | cut -d'"' -f2 | sed -e 
's/^[[:space:]]*//'

or second solution replace "links" with "elinks" or "w3m" thanks to juanmabc3<at>gmail<dot>com 

idée todo: dictionnaire automatique

- extraire d'un dico (http://www.lexique.org/) les mots qui me manquent dans ma base de vocabulaire français-russe, les copier dans un fichier plat test.fr puis:

./translateFR2EN2RU.sh

rm test.en
rm test.ru
touch test.en
touch test.ru
#now creating the list of english words
cat test.fr | while read i
do
#echo "FR: " 
#echo $i
#echo ""
#echo "EN: "
tw translate.google.com.fr-en "$i"   >> test.en
#echo "---"
done

#now creating the list of russian words
cat test.en | while read i
do
 tw translate.google.com.en-ru  "$i" >> test.ru
done
cat test.ru

après yapluka… et on a un dico français-anglais-russe à peu de frais!!!

note: on dirait que ça ne marche pas, google déconnecte après quelques dizaines de requêtes puis refuse de traduire - essayer plus tard? couper??? le mieux serait de trouver un dico tout fait… voir avec jalingo

idée todo: n'afficher que deux traductions si différentes

de freetranslate.com.de-en et de translate.google.com.de-en Roman Graf

si jamais voir la liste des langues disponibles au niveau de google et freetranslate: tv -l

fonction à mettre dans .bashrc

function twdeen(){
google="`tw translate.google.com.de-en "$1"`";
freetr="`tw www.freetranslation.com.de-en "$1"`";
if [ "${google}" = "${freetr}" ] ; then
echo "$google";
else
        echo "google: $google";
        echo "freetr: $freetr";
fi
}

usage:
twdeen 'Vergleich Uebersetzung von GOOGLE und FREETRANSLATE'
google: Compared translation by GOOGLE and FREETRANSLATE
freetr: Comparison translation of GOOGLE and FREETRANSLATE

twdeen 'Übersetzung'
Translation
 
russe/twandgtw.txt · Dernière modification: 2008/11/11 11:38 (modification externe)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki