Tue Dec 11 03:46:20 CST 2007

Spanish text linking to wordreference.com from french/spanish translation

I wanted to link every word from a text I was reading to the website wordreference.com for a spanish/french tranlsaiton so that I could click on unknown words instead of having to cut and paste every time. This is roughly what I did:
cp Homero\ -\ La\ Odisea.txt Homero\ -\ La\ Odisea.html
cat Homero\ -\ La\ Odisea.txt|sed 's/$/4444/' > Homero\ -\ La\ Odisea2.txt
cat Homero\ -\ La\ Odisea2.txt|sed 's/\w\+/\<a href\=\"http\:\/\/www\.wordreference\.com\/esfr\/\0\"\>\0\<a\> /g' > Homero\ -\ La\ Odisea3.txt
cat Homero\ -\ La\ Odisea3.txt|sed 's/4444/<br>/g'
cat Homero\ -\ La\ Odisea3.txt|sed 's/4444/<br>/g' > Homero\ -\ La\ Odisea4.html
split -l 25 Homero\ -\ La\ Odisea4.html
rename 's/$/\.html' x*
find . -iname '*.html'|cut -b3- |sed "s/^/\"/"|sed 's/$/\"/'|xargs perl -pi -e 's/charset=utf-8/charset=utf-8/'



Missing in the post is a step where I prepended a header to every .html file. I cut the files in smaller pieces to make it easier on the browser. The link to the final product is up.

Posted by Mathieu Allard