TranslateHandlerFirefox

From Apertium
Jump to navigation Jump to search

How to add an translate: handler in Firefox[edit]

You only need 3 steps:

  • Copy this script in your /usr/local/bin as moz-translate.sh
TMP=`mktemp -d`
pair=`echo $1 | cut -d : -f 2`
address=`echo $1 | cut -d : -f 3-`
echo pair:$pair addr:$address
cd $TMP
wget -k ${address} -O $TMP/index.html
apertium $pair -u -f html $TMP/index.html >$TMP/trindex.html
firefox $TMP/trindex.html
rm -Rf $TMP
  • Change the permos to that file
chmod +x /usr/local/bin/moz-translate.sh
  • Add the handler to the firefox. To do this enter in your address bar
about:config

It will ask you if you are sure. Accept.

Clic with your write button and add a "New->String"

Enter network.protocol-handler.app.translate and the value /usr/local/bin/moz-translate.sh

And voilá! The first time you try it It will ask you for associate an application you will need to give it the correct path for moz-translate.sh again.

You could now test it, enter in your addres bar:

translate:ca-es:http://www.sindicat.net