I started dabbling with FireFox add-ons yesterday. Pretty quickly I had published my first simple add-on. This post will be my documentation.
The premise is simple, I wanted to be able to highlight text then right-click and have a new Google Translate tab open with the text translated. I often highlight text, right-click then type ‘s’ to search in Google. I wanted to do the same (without switching FireFox’s search engine), but send the text to Google Translate.
The context menu shortcut key for Right-Click Translate is the letter ‘t‘.
It uses the new higher level API, so add-on can be installed without requiring FireFox to be restarted.
Install
Here is the latest version of the add-on on mozilla.org https://addons.mozilla.org/en-US/firefox/addon/right-click-translate/
Release Notes
v0.1 Released version that translates to English only.
v0.2 Added preference support to change the target language to any supported by Google Translate
v0.3.0 Tab now opens beside current tab (instead of stuck at the end of all open tabs).
-still have not delved into fixing issue with spaces as it looks like a big job, will get to it when I have time.
v0.3.1 Issue uploading to addons.mozilla.org, had to increment the version number to get it working.
v0.3.2 Added icon to menu item to make it easier to find
Future Updates
- Full page translation if no text selected
- Customizable access key (maybe ‘t’ is already taken or you do not have it on your keyboard)
Support
This plugin is pretty simple, I doubt any support will be required. However, feel free to leave a comment below if you are having trouble, find a bug, or have any suggestions.
[EDIT: Fixed! Issue fixed by Mozilla staff in Firefox internals]
NOTE TO SELF: found a bug! did not think it was possible =)
For whatever reason, gaps between paragraphs are not being read as gaps. When words are not separated or only separated by, for example, a ‘.’ the words do not get translated. This is not the only situation though, check the examples.
Here are two examples with original URLs and Google Translate URLs:
(http://www.timeout.es/barcelona/es/que-hacer/20-cosas-que-hacer-con-los-ninyos-en-verano)
https://translate.google.com/?q=#auto/en/Si%20bien%20es%20verdad%20que%20hay%20que%20hacer%20una%20reserva%20previa%20para%20poder%20entrar%2C%20llamando%20por%20tel%C3%A9fono%2C%20por%20mail%20o%20entrando%20en%20su%20web%20ya%20ten%C3%A9is%20la%20cosa%20solucionada.Tienen%20varias%20actividades%2C%20pero%20la%20m%C3%A1s%20recomendada%20para%20visitas%20en%20familia%20con%20ni%C3%B1os%20de%206%20a%2012%20a%C3%B1os%20es%20%27Descubre%20el%20CRAM%27.
(http://www.timeout.es/barcelona/es/lugares-de-interes/centre-de-recuperacio-danimals-marins)
https://translate.google.com/?q=#auto/en/Para%20visitar%20el%20centro%20hay%20que%20hacer%20reserva%20previa%20llamando%20por%20tel%C3%A9fono%20o%20mandando%20un%20e-mail%20a%20reserves%40aulacram.comTienen%20varias%20actividades%2C%20pero%20la%20m%C3%A1s%20recomendada%20para%20visitas%20por%20familias%20con%20ni%C3%B1os%20de%206%20a%2012%20a%C3%B1os%20es%20la%20de%20%27Descobreix%20el%20CRAM%27.
Would you consider adding firefox Electrolysis support?
Thank you.
You are not the first person to ask me this for some reason. So I will post this answer here for all to see.
I cannot see what benefits there would be in adding Electrolysis support. This add-on is essentially a one-liner that opens a new tab. There are no background processes. There is no need for more than one thread. I cannot see why it would need to be sand-boxed for security (if you can think of a use-case let me know).
So there you go, I have considered it. There is no point in using it in this very basic and simple add-on :-)