MediaWiki talk:Gadget-dictionaryLookupHover.js

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

See WN:WiktLookup for more information.

Note: This script currently does not have a maintainer. If you know Javascript, HTML, and (a little) XSLT, and you don't mind spaghetti code, please feel free to help out or take over maintaining the script.


This script is currently broken by bugzilla:39180

FAQ[edit]

  • I want to use this, but at the same time I want to be able to double-click things without the pop-up coming up. (aka i want to use the edit when double clicking option, or i want to select whole words by double clicking).
    • hold down shift while double clicking
  • Can this be translated into <some language>
    • yep, this is already in several languages. See below to request a new translation, or help with translation
  • Can I use this on my website or wiki
  • I know javascript and want to help
  • I for some reason want to query wiktionary for definitions
  • I want to use this as a bookmarklet
    • Sure, just bookmark the following url (In firefox, highligh it and drag to toolbar)

javascript:(function%20()%20%7Bvar%20src%20=%20document.createElement('script');src.type%20=%20'text/javascript';src.src%20=%20'http://en.wikinews.org/w/index.php?title=MediaWiki:WiktionaryLookup-external-bookmarklet.js&action=raw&ctype=text/javascript&scrver=1';document.getElementsByTagName('head')%5B0%5D.appendChild(src);%7D)();void%200

  • I want to disable it for a paticular section of a page
    • just enclose that section in <span class="wiktLookup-disable">text here</span>. (doesn't have to be a span, could be any element. also recognizes class name wiktLookup-enable to override).

Random idosynchrasis[edit]

  • The count parameter will only return definitions for the word as interperted as if the word is of a specific language. However ES translation does all definitions
  • Image handling kind of crap.

Open issues[edit]

  • Determine if - is a valid word separator. perhaps try both. What about _.
    • Better handling of compound words ( word-word ).
  • Issues with xslt
    • maybe bug link. (not happening right now, as i'm worried it will make things too clutered, but if people really want it, please yell at me)
  • Better instructions. (preferably with pictures)
  • integrate some stuff from fr wiktionary
  • count parameter. push to NL
  • showWord parameter. push to NL
  • get permission to steal wikt:MediaWiki:langcode2name.js
  • Investigate possibility of word press plugin, grease monkey script.
  • Have it recognize if its out of date, and make it do a hard refresh.
  • Double click on search box on mediawiki. (Scroll wheel or something)

Longer term/ stuff i'm aware but not on my immediate list of things to fix (yell at me if you think these are important and should be a priority)

  • Image captions are not stripped even though image is. EX: web (A spider's web at end should not be there)

Other requests (aka stuff other people reported that i'm not planning to do in short term):

I could see how that could be useful (adding a bug report page link), but i don't want to make the interface too cluttered. As for your second request. It currently says, can not find word, and has a more link which links to the page. that should probably be improved. thank you for the feedback. Bawolff 00:56, 21 October 2009 (UTC)[reply]
  • This is very cool; I've been giving a spin on my blog. A few bugs and requests:
    • There is no way to select compound words (either hyphenated or non-hyphenated)
      • It now considers a hyphen as part of a word. However this introduces problems with hyphanated words that are really two words (example from your blog scientist-historians) . Ideally it should first check the entire thing, than try to see if just one part of the hyphanated word works. I don't know what you mean by non-hyphenated compound words.). - bawolff


Browser-related potential problem[edit]

Firefox extension noscript may block scripts from en.wikinews, resulting in issues as pictured here. Solution: Have user whitelist wiktionary.org resolved this problem. - Amgine | t 21:48, 7 November 2009 (UTC)[reply]

I wouldn't really clasify this as a problem - if someone disables javascript, they should not be suprised when the javascript does not work. (the issue above would be blocking scripts from wiktionary (with either xslt defined as a script or having css disabled as well) - as if you had either en wikinews, or fr wikinews blocked, you would not be able to get to that step) Bawolff 22:09, 7 November 2009 (UTC)[reply]

Clic or shortcut?[edit]

[...]Au lieu du double-clic ou triple-clic pour le gadget, on peut utiliser une combinaison de touche clavier (Ctrl+F11 par ex) que l'utilisateur peut changer.

[...]Instead of double-clic third-clic and so one, we could use a key-combination (Ctrl+F11 by ex) that the user could change. Otourly (talk) 13:21, 14 November 2009 (UTC)[reply]
[1] hop Otourly (talk) 13:24, 14 November 2009 (UTC)[reply]
If we use a key combo, how do we know which word to lookup. unless he means single-click, plus a key combo. Bawolff 22:59, 15 November 2009 (UTC)[reply]
I agree with this request as an aditional alternative (not instead of double-clicking). We can perform a partial selection of words or a combined selection of a phrasal verb and then use the key-combination shortcut. Gustronico (talk) 17:44, 21 November 2009 (UTC)[reply]
That sounds like a good idea. Bawolff 04:08, 22 November 2009 (UTC)[reply]
  • Done. ctrl+shift+L looks up word. (can be configured to be ctrl+shift+anycharacter).
That's good. Thank you! Gustronico (talk) 08:15, 28 November 2009 (UTC)[reply]

Japanese word margins[edit]

According to Makato, determining word boundaries may be a problem for the script in Japanese. - Amgine | t 18:27, 18 November 2009 (UTC)[reply]

  • Done highlight and use key combo ctrl+shift+l

Request for translations[edit]

See /how to adapt to another language. Or you could just leave the translation here, but it might take me a little while to get to it.

Languages available[edit]

  unstable xslt example (unstable) live xslt enabled
Deutsch waiting on Bawolff non-exisitant  
English good

[2] [3] [4] [5] high count

slightly outdated X
Español Good [6] slightly outdated X
Français good [7] up to date X
Italiano good [8] slightly outdated X
Japanese Good Installed x
Latin waiting on Bawolff   non-existant  
Nederlands outdated [9] good X
Norsk (bokmål)‬ waiting on translation non-exisitant  
Polish waiting bawolff [10] not ready  
Portuguese done [11] updated X
Русский good [12] [13] [14] done x
中文 To translate and fix the single word selection bug
हिन्दी To translate

Want this in your language? To speed up the process, consider helping me by translating the following messages ($1 is where stuff gets substituted. leave it in) (Please also specify language code, as well as an admin contact at the specific language wiktionary in question whom i can bug with with re-sync requests)

  • © Wiktionary. Released under CC-BY-SA 3.0
    • Don't worry about urls, i can translate those.
  • Error:
  • » More
    • Note: bear in mind the » may not be a good arrow depending on your language.
  • » Create
  • Could not retrieve definition of $1.

Deutsch (DE)(left to right)[edit]

  • © Wiktionary. Unter der CC-BY-SA 3.0 Lizenz verfügbar.
  • Fehler:
  • » Weiter
  • Neuen Eintrag erstellen
  • Nicht möglich, die Definition von $ 1 abzurufen

PL[edit]

EL[edit]

Here is a translation of this points:

  • © Βικιλεξικό. Διανέμεται υπό την CC-BY-SA 3.0
  • Σφάλμα:
  • » Περισσότερα
  • » Δημιουργία
  • Δεν ήταν δυνατόν να ανακτηθεί ο ορισμός του $1.

--Egmontaz συζήτηση 17:55, 20 Νοεμβρίου 2009 (UTC)

From: [15] Otourly (talk) 18:16, 20 November 2009 (UTC)[reply]

LA[edit]

Latin translation, from Wiktionary's EncycloPetey:

More work for Bawolff! \o/ - Amgine | t 21:48, 21 November 2009 (UTC)[reply]

CA[edit]

  • © Viccionari. Disponible sota CC-BY-SA 3.0
  • Error:
  • » Més
  • » Crea-la
  • No s'ha trobat cap coincidència per a «$1».

Pasqual (talk) 17:56, 7 December 2009 (UTC)[reply]

EO[edit]

  • © Vikivortaro. Publikigita sub kopirajto CC-BY-SA 3.0
  • Eraro:
  • » Pli
  • » Krei
  • Ne povis obteni difinon de «$1».

[16]--→ Airon Ĉ 12:11, 30 December 2009 (UTC) —Preceding unsigned comment added by Otourly (talkcontribs) [reply]

Translation and Translatewiki[edit]

Why do you not transform the LookupHover javascript in a Wikimedia extensions and use the power of the translatewiki ? Crochet.david (talk) 18:32, 12 November 2009 (UTC)[reply]

That would take it from a simple javascript to requiring it's own extension? That doesn't seem...good. --ShakataGaNai ^_^ 18:39, 12 November 2009 (UTC)[reply]
For now, it's a simple javascript. But one never knows what the future holds.Crochet.david (talk) 18:46, 12 November 2009 (UTC)[reply]
I think the point is that it is simple javascript and doesn't need to be anything more, since it already does it's job. Plus if you make it a mediawiki plugin then you can't propagate it out to blogs and such. --ShakataGaNai ^_^ 18:49, 12 November 2009 (UTC)[reply]
If it were to become an extension, it would essentially be an extension that just loaded a script. (which i geuss there is nothing wrong with, some people might find that easier to install). However the issue with translatewiki, which well very appealing, the translation doesn't just involve translating a few key phrases, it also involves modifying some rather complicated (And quite fragile) regexs that screen scrape wiktionary, since each language definition uses slightly different markup. This requires some technical knowladge, beyond simply translating words. Bawolff 19:51, 12 November 2009 (UTC)[reply]

Problem with French language[edit]

Accents at begin and end of words are legal in many languages. For example, on French wikibooks, when I click on "désactivé" word, I get "Could not retrieve definition of desactiv".

Also error messages should be translated. --DavidL (talk) 23:50, 14 November 2009 (UTC)[reply]

The error message is translated (I could [have] sworn that was translated. must be losing my mind. Its translated now, just needs to be posted to fr wiktionary.). When I click on the word, I get "(Français) Du verbe désactiver." [17] The issue with accents at the end of the word was fixed weeks ago. Perhaps you have an old (really old) cached version of the script. Try doing a hard refresh of the page where you clicked the word. Apperently this is a different issue with accents (Its caused by their being extra whitespace at the end of the word that was not stripped properly). If you do a hard refresh it should be fixed now. Thanks for the bug report. Bawolff 05:24, 15 November 2009 (UTC)[reply]

Particularity of the Wikizionario[edit]

Hi, for the wikt it, Wim_b has requested me that we should add the local project feedback:

  • If I don't know the word, two links: "crea" (create it) or "richiedila" (request it)

The second link should be associated to it:wikt:Wikizionario:Feedback by adding a new section with the article link in title. Then the user will complete the body of the request. Otourly (talk) 22:30, 15 November 2009 (UTC)[reply]

That should definitly be do-able. Should the bottom link look as follows (If it was an entry for sample word):

» Crea » richiedila

? Bawolff 22:56, 15 November 2009 (UTC)[reply]

Wim_b have ask this it:wikt:Wikizionario:Bar#Considerazioni; It work with china writing [18]! I'm proud of you! Otourly (talk) 23:48, 15 November 2009 (UTC)[reply]
On en wikt they also have a feedback but it seems more difficult for edit wikt:Wiktionary:Feedback (monthly self-archive) Otourly (talk) 00:00, 16 November 2009 (UTC)[reply]

Phonetic and sound[edit]

As a good seller, I've promised the moon to to convince Wikispecies:Wikispecies:Village_Pump#Wiktionary_Hover:_a_JavaScript_on_double-click: is it possible to start the development of the displaying of the wiktionaries phonetic and sound, which would ones of the most important aspect of this project, please? JackPotte (talk) 22:27, 16 November 2009 (UTC)[reply]

Yes, but it'd take time. This would have to be implemented for each language seperately. Bawolff 13:25, 17 November 2009 (UTC)[reply]

Reach[edit]

Otourly is tracking the ever-expanding reach of wiktLookUp. - Amgine | t 04:01, 17 November 2009 (UTC)[reply]

Wow, thats awesome. Bawolff 13:26, 17 November 2009 (UTC)[reply]

Feedback from the Chinese side[edit]

As our fellow said, there's a very big problem with ideograms ;). JackPotte (talk) 14:08, 21 November 2009 (UTC)[reply]

Script conflicts with "Edit pages on double-click"[edit]

I'm using the script on Commonms and also have "Edit pages on double-click" activated in the preferences. Unfortunately, both parts can't be used together (unoess on special pages, which are localized almost anytime). It would be great if you could find another way than double-clicking. (See also User talk:Otourly on Commons where I originally asked this). --The Evil IP address (talk) 23:52, 28 November 2009 (UTC)[reply]

There's a couple ways arround this. First of all, you can hold down shift well double clicking to edit, and not hold down shift to look up a word. Second of all, you can enable the reverseShift option (If your not sure how to do that, i can help you), and use the key combo ctrl+shift+l to look things up. Cheers. Bawolff 18:20, 29 November 2009 (UTC)[reply]

Unhiding too early[edit]

Displaying the window first and changing its contents second is ugly. Try doubleclicking on a word, then clicking away to hide the window, then doubleclicking another. First the previous definition will show up, then an empty window with the (C) footer, and the actual definition only after that. --Tgr (talk) 08:57, 4 December 2009 (UTC)[reply]

Done You're right that is ugly. It should now be fixed. Thankyou for your feedback. Bawolff 17:15, 4 December 2009 (UTC)[reply]

IE bug[edit]

Please see this report. JackPotte (talk) 11:34, 3 September 2010 (UTC)[reply]

Place to function[edit]

Someone on the French Wikinews is asking for the tool deactivation in the modifiable frame in Safari (which isn't the case on Firefox). JackPotte (talk) 16:48, 3 September 2010 (UTC)[reply]

Sorry, I don't think i understand. deactivating on safari should be same as firefox. Bawolff 18:54, 9 September 2010 (UTC)[reply]

Catalan[edit]

Hi, I've tested Catalan Wiktionary here, but It doesn't retrieve Catalan definitions. How can I help? --Unjoanqualsevol (talk) 19:15, 17 November 2010 (UTC)[reply]

Hi. Officially I've stopped supporting this tool, but your issue is an easy fix - On line 85 of wikt:ca:Mediawiki:extractFirst.xsl change:
  var extractCurLangName = /<h2>\s*<span[^>]*?>\[<a[^>]*?>\w+<\/a>\](?:<\/?span[^>]*>\s*){,2}<a[^>]*>(.+?)<\/a>(?:<\/span>){,2}<\/h2>$/; //first subexpression

to

 var extractCurLangName = /<h2>\s*<span[^>]*?>\[<a[^>]*?>\w+<\/a>\](?:<\/?span[^>]*>\s*){0,3}<a[^>]*>(.+?)<\/a>(?:<\/span>){0,2}<\/h2>/; //first subexpression

and that should hopefully fix the issue. Bawolff 20:12, 17 November 2010 (UTC)[reply]

Thanks for quick support. I've contacted with a Catalan Wiktionary admin to make theses changes. Regards,--Unjoanqualsevol (talk) 12:12, 19 November 2010 (UTC)[reply]

Persion Translations (Right-to-Left)[edit]

Mjbmr Talk 22:22, 2 February 2011 (UTC)

Protocol Relative URLs[edit]

Hi,

Could someone please remove all references to the http protocol from this script, to use protocol relative URLs instead?

Examples:

This is a major issue for the new https://wikiwhatever.org scheme to work.

Thanks in advance — Arkanosis 14:59, 2 October 2011 (UTC)[reply]

Compatibility with Template:lang[edit]

Would it be possible to implement a section selection according to the CSS code of the targeted word, defined through Template:lang? JackPotte (talk) 19:26, 12 January 2012 (UTC)[reply]

WiktLookup.supported() too narrow[edit]

WiktLookup.supported() returns false when using Chrome 16. After manually changing to true, it works perfectly. --Tgr (talk) 21:29, 7 February 2012 (UTC)[reply]

Can't create the targeted page[edit]

When the following message appears: The page you specified doesn't exist, there is still the mention to read the full article but without the, whereas we logically should see the link to create it on the Wiktionary. JackPotte (talk) 17:01, 12 August 2012 (UTC)[reply]

PS: The page you specified doesn't exist isn't translated as well. JackPotte (talk) 17:03, 12 August 2012 (UTC)[reply]

Complete failure[edit]

Since the last Mediawiki migration, this script doesn't work anymore on all the wikis. Actually, the only action is "GET http://en.wiktionary.org/w/api.php?action=parse&redirects&prop=text&format=xml&xslt=MediaWiki:extractFirst.xsl&page=have%20&lang=en [HTTP/1.0 200 OK 468ms]". So in Firefox 16 we can see nothing, with Chrome it opens a new tab, and IE and Safari open a new window. JackPotte (talk) 19:59, 14 November 2012 (UTC)[reply]

Sorry yeah - the fix for bugzilla:39180 broke wiktLookup on non-ancient browsers. Bawolff 23:54, 16 November 2012 (UTC)[reply]
Thanks for your answer, we could maybe use the tricks which already works for the recent Firefox users into Wiktionary and Google Translate. JackPotte (talk) 10:57, 17 November 2012 (UTC)[reply]

Target=blank?[edit]

The gadget always opens new window when I double-click. Can it be changed to be a box at the same page? Infovarius (talk) 12:30, 2 June 2017 (UTC)[reply]

It doesn't work at all for me: Gadget "dictHover" was not loaded. Please migrate it to use ResourceLoader.
Moreover, I have thought we could repair the old XSS blocking problem we had with a mw.ForeignApi().
JackPotte (talk) 09:16, 25 June 2017 (UTC)[reply]
My impression is this gadget hasn't worked for a long time. It's not within my expertise, though. Possibly Amgine might know something. --Pi zero (talk) 13:49, 25 June 2017 (UTC)[reply]
I believe this tool has been unmaintained since at least 2012. It was a very brittle model, requiring continuous updating and maintenance. On another hand, it showed one way the sister projects could coordinate trans-project, and in that it was a great success. - Amgine | t 14:18, 25 June 2017 (UTC)[reply]

ReferenceError: hookEvent is not defined[edit]

{{Editprotected}}

This script now throws the following error : ReferenceError: hookEvent is not defined

Because there is a try/catch, usually the script should silently fail, but in some scenarios the script still breaks and stops execution of all the next scripts…

This script is loaded by other wikis… To fix it, there are simply two callbacks to migrate to jQuery.

References:

Od1n (talk) 00:54, 7 July 2017 (UTC)[reply]

@Od1n: I was under the impression this gadget has not worked for years, not just since late 2016. See the preceding thread. --Pi zero (talk) 12:25, 7 July 2017 (UTC)[reply]
Unmaintained is not quite the same as completely broken; I understand most of it still works on some of the wikis it is enabled on. - Amgine | t 14:17, 7 July 2017 (UTC)[reply]
We encountered a strange issue on fr.wiki, when using importStylesheet() was kind of making ineffective the try/catch of this externally loaded gadget, thus encountering the reported fatal error and breaking all the next scripts. This really has to be fixed.
A few tips for the (straightforward) jQuery migration:
  • jQuery makes available a normalized event.which that you can use instead of (event.charCode ? event.charCode : event.keyCode)
  • return false already includes preventDefault() and stopImmediatePropagation()
Od1n (talk) 15:08, 7 July 2017 (UTC)[reply]
@Od1n:: Because no one on en.WN is maintaining this script, I would suggest you copy the script to fr.WP and make the changes you see as necessary to fix it. You will likely also need the xslt. I believe JackPotte could be helpful in maintaining the xslt. - Amgine | t 15:37, 7 July 2017 (UTC)[reply]
The XSLT is loaded from the Wiktionary, so it is not applicable to fork it. But maybe I overlooked something? Od1n (talk) 21:09, 7 July 2017 (UTC)[reply]
Update: I forked the script and applied the fixes at fr:w:MediaWiki:Gadget-dictionaryLookupHover.js, and indeed, now I am encountering this error when querying a term: Load denied by X-Frame-Options: https://fr.wiktionary.org/w/api.php?action=parse&redirects&prop=text&format=xml&xslt=MediaWiki:extractFirst.xsl&page=foobar&lang=fr does not permit framing. Od1n (talk) 22:31, 7 July 2017 (UTC)[reply]
This is clearly not settled, but it doesn't seem to be a realistically pending edit-request, either. --Pi zero (talk) 22:28, 9 May 2018 (UTC)[reply]
This script does not work. It's throwing a lot of errors in production so I've disabled it for now. Jon (WMF) (talk) 18:55, 9 September 2020 (UTC)[reply]