Saturday, October 24, 2009

Introducing Wiktionary lookup. Now for blogs


At the urging of Amgine, I've been developing a gadget for Wikimedia projects that looks up a word you double click in Wiktioary. (It is based on a gadget from french Wikinews by User:Conrad.Irwin and User:Bequw) Anyways, I've been told that some people want to use it on there blog, so now you can. All you have to do is insert somewhere in the <head> of your html document:


<script src='http://en.wikinews.org/w/index.php?title=MediaWiki%3AWiktionaryLookup-external.js&amp;action=raw&amp;ctype=text/javascript' type='text/javascript'></script>

Then whenever someone double-clicks a word, the definition will popup (See diagram at top). Its currently enabled on this blog (as well as several Wikimedia projects). Please try it out and let me know what you think.

Some notes:

  • It detects the language from the lang attribute on <html> (note thats lang, not xml:lang) It will also look in js global variable wgContentLanguage for the current language.

  • Supports english (EN), french (fr, frc), Dutch (nl). Translations welcome.

  • This is still a work in progress. Expect improvements. Bug reports can go on [[n:Mediawiki_talk:Gadget-dictionaryLookupHover.js]]. There are also some generic instructions on [[n:WN:WiktLookup]]

  • Current browser support is: Full support on Firefox, Safari. Partial support on Konqueror, Internet explorer (requires xslt support for full support. IE doesn't work due to mediawiki using a mime type that IE doesn't recognize as xslt). Theoretically should have full support on Opera, but have not tested.


Update: now with compound word support.

11 comments:

  1. I'm testing it out on my blog. The biggest complaint I have so far is that there's no way (that I can tell) to look up compound words.

    But I like how it points you to the empty page for words that aren't in Wiktionary, so that you can create an entry.

    ReplyDelete
  2. I'm planning to at some point change the word does not exist message to have the more link become a create link, which wil hopefully make it more clear people can write new definitions.

    I made some improvements to the part that selects a word from the text, so now it should recognize compound words.

    Cheers.

    ReplyDelete
  3. I'm considering trying to make a wordpress widget/plugin (not sure right terminology) to make this easy, but havn't done that yet. In the mean time you have to edit the wordpress theme file. Specificly you have to alter the header (usually contained in the wp-content/themes/header.php file of the theme, but sometimes varries)
    Look for the part that starts with <head>. Add the script tag listed above exactly after that. So it should look something like:

    (some stuff...)   <head><script src='http://en.wikinews.org/w/index.php?title=MediaWiki%3AWiktionaryLookup-external.js&amp;action=raw&amp;ctype=text/javascript' type='text/javascript'></script>    (plus some more content after that)

    Make sure to keep backups, and test after doing that. Contact me if you need any help.

    ReplyDelete
  4. Erreur lors du chargement de la feuille de style : Une erreur réseau s'est produite lors du chargement d'une feuille de style XSLT :
    http://en.wiktionary.org/w/index.php?title=MediaWiki:extractFirst.xsl&action=raw

    Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13

    ReplyDelete
  5. Its also possible that firefox 2 does not recognize the mime type mediawiki sends with the stylesheet (mediawiki does not follow standards in this area). However it works in firefox 3, so i'm not sure if thats it.

    ReplyDelete
  6. Hi !
    I'm trying to install this script on my blogger blog, but it doesn't seem to run properly.
    I tried to put it right after my head element but got a parsing error (elements "action" and "ctype" need to be closed with a ";"). I then tried to put it in a javascript widget in my header or my sidebar (I do that for most of my scripts) but it didn't work. Am I missing something ?
    Thanks in advance for any help,
    Fred

    ReplyDelete
  7. That is a very weird error. I'm not sure what could cause it.

    Are you sure you put copied the snippet exactly

    <script src='http://en.wikinews.org/w/index.php?title=MediaWiki%3AWiktionaryLookup-external.js&amp;action=raw&amp;ctype=text/javascript' type='text/javascript'></script>


    including the space between script and src? It might help if you could show me (in a pastebin ) exactly what the code you used is.

    ReplyDelete
  8. Thank you for your quick answer ! Don't ask me why but I tried again this morning and it works perfectly ! @_@ The only difference is that, yesterday, I copy-pasted the code from here and also from the source code of this blog ; today I just grabbed the one you just quoted for me.
    Anyway, it works perfectly now : such a nice script ! I wanted to use it as a translation tool by making it look in the Japanese Wiktionnary, but it appears it doesn't have many French words. Too bad, but my students will be happy to have at least an explanation in French and the pronunciation !
    Thanks again for this great script : if you need some help with the project and if I can help (I'm more a copy/paster than a real programmer >_<), I will be glad to do so.
    Fred

    ReplyDelete
  9. Glad to hear it works. Its nice to see there are still people interested in it over a year after I originally published it.

    ReplyDelete