jQuery Rotate Through Other Languages


jQuery code snippet to show other languages link (say in the footer) of your web page. It randomly shows other languages available with a link to change the language of the website. It is set to change every 5 seconds but this can be optimised as well as the array of languages displayed.

jQuery Code

(function (b) {
	var c = ['<span lang="ar">العربية</span>', '<span lang="el">Ελληνικά</span>', '<span lang="pl">Polski</span>', '<span lang="bs">Bosanksi</span>', '<span lang="id">Bahasa Indonesia</span>', '<span lang="ru">Русский</span>', '<span lang="zh">中文</span>', '<span lang="it">Italiano</span>', '<span lang="sr">српски</span>', '<span lang="hr">Hrvatski</span>', '<span lang="ja">日本語</span>', '<span lang="es">Español</span>', '<span lang="fr">Français</span>', '<span lang="ko">한국어</span>', '<span lang="tl">Tagalog</span>', '<span lang="de">Deutsch</span>', '<span lang="fa">فارسی</span>', '<span lang="vi">Tiếng Việt</span>'];
	var a = document.doctype ? document.doctype.publicId : document.firstChild.data;
	var d = a.indexOf("XHTML") > 0;
	updateLanguage = function () {
		b("#languages a").empty().append(c[Math.floor(Math.random() * c.length)] + " (Other languages)");
		if (d) {
			b("#languages span").attr("xml:lang", b("#languages span").attr("lang"))
	window.setInterval(updateLanguage, 5000)


<li id="languages"><a href="[yourlink]">Other languages</a></li>