MediaWiki:Gadget-WiktSidebarTranslation.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

See also: Special:Gadgets.


$(function(){
	$("#p-lang .interlanguage-link a").each(function(){
		var langnameMatch = $(this).attr("title").match(/(.*) – (.*)/);
		var langname = $(this).attr("title"); //some wiktionaries like afrikaans have '' as their main page
		if (langnameMatch && langnameMatch.length >= 3) langname = langnameMatch[2];

		$(this).text(langname)
			.attr("lang", "en");//this line breaks compact languages
	});
	
	$("#p-lang .interlanguage-link").sort(function(lia, lib){
		return $(lia).children().first().text() < $(lib).children().first().text() ? -1 : 1;
	}).appendTo("#p-lang>div>ul");
});