MediaWiki:Gadget-TranslationAdder-Data.js

De Viccionari

Nota: Després de publicar, possiblement necessitareu refrescar la memòria cau del vostre navegador per a veure'n els canvis.

  • Firefox / Safari: Premeu Majús i alhora cliqueu el botó Actualitzar, o pressioneu Ctrl+F5 o Ctrl+R (⌘+R en un Mac)
  • Google Chrome: Premeu Ctrl+Majús+R (⌘+Shift+R en un Mac)
  • Internet Explorer / Edge: Premeu Ctrl i alhora cliqueu a Actualitza o pressioneu Ctrl+F5
  • Opera: Premeu Ctrl-F5.
// {{documentation}}
// <nowiki>
// implicit dependencies : none (was mediawiki.api,ext.gadget.LanguageUtils currently not used)
/* jshint maxerr:1048576, strict:true, undef:true, latedef:true, es5:true */
/* global $, ScriptUtils, mw */

window.LangMetadata = function() {
	//Singleton
	if (arguments.callee.instance)
		return arguments.callee.instance;
	else
		arguments.callee.instance = this;

	// {{{ Metadata dictionaries
	// FIXME: Is it possible to query this information directly from [[Module:languages]]?
	var metadata = {
		aa: {
			sc: ["Latn", "Ethi"]
		},
		ab: {
			sc: ["Cyrl", "Latn", "Geor"]
		},
		af: {
			g: ["s", "p"]
		},
		akk: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Xsux"]
		},
		am: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Ethi"]
		},
		an: {
			g: ["m", "f", "m-p", "f-p"],
			haswikt: 1
		},
		ang: {
			alt: 1,
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		ar: {
			alt: 1,
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Arab"]
		},
		arc: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Hebr", "Syrc"]
		},
		arz: {
			alt: 1,
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Arab"]
		},
		as: {
			sc: ["Beng"]
		},
		ase: {
			allowCaps: 1
		},
		ast: {
			g: ["m", "f", "m-p", "f-p"]
		},
		az: {
			g: ["s", "p"],
			sc: ["Latn", "Cyrl", "Arab"]
		},
		ba: {
			sc: ["Cyrl"]
		},
		"bat-smg": {
			g: ["m", "f", "m-p", "f-p"]
		},
		bbl: {
			sc: ["Geor"]
		},
		be: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"],
			trauto: 1
		},
		"be-x-old": {
			sc: ["Cyrl"]
		},
		bg: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"]
		},
		bh: {
			sc: ["Deva"]
		},
		bhb: {
			sc: ["Deva"]
		},
		blt: {
			sc: ["Tavt"]
		},
		bm: {
			sc: ["Latn", "Nkoo", "Arab"]
		},
		bn: {
			sc: ["Beng"]
		},
		bo: {
			sc: ["Tibt"]
		},
		br: {
			g: ["m", "f"]
		},
		cdo: {
			sc: ["Hani"]
		},
		ce: {
			sc: ["Cyrl"]
		},
		chr: {
			sc: ["Cher"]
		},
		cjy: {
			sc: ["Hani"]
		},
		ckb: {
			sc: ["Arab"],
			wsc: ["ku-Arab"]
		},
		cmn: {
			sc: ["Hani"]
		},
		cpx: {
			sc: ["Hani"]
		},
		cr: {
			sc: ["Cans"]
		},
		cs: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		csb: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		csc: {
			allowCaps: 1
		},
		cu: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrs", "Glag"]
		},
		cv: {
			sc: ["Cyrl"]
		},
		cy: {
			g: ["m", "f", "m-p", "f-p"]
		},
		czh: {
			sc: ["Hani"]
		},
		czo: {
			sc: ["Hani"]
		},
		da: {
			g: ["c", "n", "c-p", "n-p"]
		},
		de: {
			g: ["m", "f", "n", "p"],
			allowCaps: 1
		},
		dng: {
			sc: ["Cyrl"]
		},
		dsb: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		dv: {
			g: ["s", "p"],
			sc: ["Thaa"]
		},
		dz: {
			sc: ["Tibt"]
		},
		el: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Grek"],
			trauto: 1
		},
		en: {
			g: ["s", "p"]
		},
		eo: {
			g: ["s", "p"]
		},
		es: {
			g: ["m", "f", "m-p", "f-p"]
		},
		et: {
			g: ["s", "p"]
		},
		ett: {
			g: ["s", "p"],
			sc: ["Ital"]
		},
		eu: {
			g: ["s", "p"]
		},
		fa: {
			sc: ["Arab"],
			wsc: ["fa-Arab"]
		},
		fi: {
			g: ["s", "p"]
		},
		fo: {
			g: ["m", "f", "n"]
		},
		fr: {
			g: ["m", "f", "m-p", "f-p"]
		},
		frm: {
			g: ["m", "f", "m-p", "f-p"]
		},
		fro: {
			g: ["m", "f", "m-p", "f-p"]
		},
		fsl: {
			allowCaps: 1
		},
		fur: {
			g: ["m", "f", "m-p", "f-p"]
		},
		fy: {
			g: ["c", "n", "p"]
		},
		ga: {
			g: ["m", "f", "m-p", "f-p"]
		},
		gan: {
			sc: ["Hani"]
		},
		gd: {
			g: ["m", "f", "m-p", "f-p"]
		},
		gez: {
			sc: ["Ethi"]
		},
		gl: {
			g: ["m", "f", "m-p", "f-p"]
		},
		gmy: {
			sc: ["Linb"]
		},
		got: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Goth"]
		},
		grc: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["polytonic"],
			trauto: 1
		},
		gsw: {
			g: ["m", "f", "n", "p"],
			allowCaps: 1
		},
		gu: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Gujr"]
		},
		hak: {
			sc: ["Hani"]
		},
		har: {
			sc: ["Ethi"]
		},
		he: {
			alt: 1,
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Hebr"]
		},
		hi: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Deva"]
		},
		hif: {
			sc: ["Latn", "Deva"]
		},
		hit: {
			sc: ["Xsux"]
		},
		hr: {
			g: ["m", "f", "m-p", "f-p"]
		},
		hrx: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		hsb: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		hsn: {
			sc: ["Hani"]
		},
		hu: {
			g: ["s", "p"]
		},
		hy: {
			sc: ["Armn"],
			trauto: 1
		},
		ike: {
			sc: ["Cans"]
		},
		ikt: {
			sc: ["Cans"]
		},
		is: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		it: {
			g: ["m", "f", "m-p", "f-p"]
		},
		iu: {
			sc: ["Cans"]
		},
		ja: {
			sc: ["Jpan"],
			trauto: 1
		},
		ka: {
			sc: ["Geor"],
			trauto: 1
		},
		khb: {
			sc: ["Talu", "Lana", "Thai"]
		},
		kjh: {
			sc: ["Cyrl"]
		},
		kk: {
			sc: ["Cyrl"],
			trauto: 1
		},
		kkh: {
			sc: ["Lana", "Thai"]
		},
		km: {
			sc: ["Khmr"]
		},
		kmr: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		kn: {
			sc: ["Knda"]
		},
		ko: {
			sc: ["Kore"],
			trauto: 1
		},
		krc: {
			g: ["s", "p"],
			sc: ["Cyrl"]
		},
		ks: {
			sc: ["Arab", "Deva"],
			wsc: ["ks-Arab"]
		},
		ku: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Arab", "Latn"],
			wsc: ["ku-Arab"]
		},
		ky: {
			sc: ["Cyrl"],
			trauto: 1
		},
		la: {
			alt: 1,
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
		},
		lb: {
			g: ["m", "f", "n", "p"],
			allowCaps: 1
		},
		lez: {
			sc: ["Cyrl"]
		},
		lld: {
			g: ["m", "f", "m-p", "f-p"]
		},
		lmo: {
			g: ["m", "f", "m-p", "f-p"]
		},		
		lo: {
			sc: ["Laoo"]
		},
		lt: {
			alt: 1,
			g: ["m", "f", "m-p", "f-p"]
		},
		lv: {
			g: ["m", "f", "m-p", "f-p"]
		},
		lzz: {
			sc: ["Geor"]
		},
		mk: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"]
		},
		ml: {
			sc: ["Mlym"]
		},
		mn: {
			sc: ["Cyrl", "Mong"]
		},
		mnp: {
			sc: ["Hani"]
		},
		mo: {
			sc: ["Cyrl"]
		},
		mol: {
			sc: ["Cyrl"]
		},
		mr: {
			g: ["m", "f", "n"],
			sc: ["Deva"]
		},
		ms: {
			sc: ["Latn", "Arab"]
		},
		mt: {
			g: ["m", "f"]
		},
		my: {
			sc: ["Mymr"]
		},
		nan: {
			sc: ["Hani"]
		},
		nb: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		"nds-de": {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		"nds-nl": {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		ne: {
			sc: ["Deva"]
		},
		nl: {
			g: ["m", "f", "n", "p"]
		},
		nn: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		no: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		nod: {
			sc: ["Lana"]
		},
		non: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		oc: {
			g: ["m", "f", "m-p", "f-p"]
		},
		or: {
			sc: ["Orya"]
		},
		orv: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrs"]
		},
		osc: {
			sc: ["Ital"]
		},
		ota: {
			sc: ["Arab"],
			wsc: ["ota-Arab"]
		},
		pa: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Guru", "Arab"]
		},
		pdt: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		peo: {
			sc: ["Xpeo"]
		},
		phn: {
			sc: ["Phnx"]
		},
		pi: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		pl: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		pms: {
			g: ["m", "f", "m-p", "f-p"]
		},
		pox: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		ps: {
			g: ["m", "f", "m-p", "f-p", "p"],
			sc: ["Arab"],
			wsc: ["ps-Arab"]
		},
		pt: {
			g: ["m", "f", "m-p", "f-p"]
		},
		rgn: {
			g: ["m", "f", "m-p", "f-p"]
		},		
		rm: {
			g: ["m", "f"]
		},
		ro: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Latn", "Cyrl"]
		},
		ru: {
			alt: 1,
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"],
			trauto: 1
		},
		rue: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"]
		},
		ruo: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		rup: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		ruq: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		sa: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Deva"]
		},
		sah: {
			sc: ["Cyrl"]
		},
		scn: {
			g: ["m", "f", "m-p", "f-p"]
		},
		sd: {
			sc: ["Arab"],
			wsc: ["sd-Arab"]
		},
		sh: {
			alt: 1,
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Latn", "Cyrl"]
		},
		si: {
			sc: ["Sinh"]
		},
		sk: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		sl: {
			alt: 1,
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		spx: {
			sc: ["Ital"]
		},
		sq: {
			g: ["m", "f"]
		},
		sr: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		sux: {
			sc: ["Xsux"]
		},
		sv: {
			g: ["c", "n", "c-p", "n-p"]
		},
		sva: {
			sc: ["Geor"]
		},
		sw: {
			nclass: 1
		},
		swl: {
			allowCaps: 1
		},
		syc: {
			sc: ["Syrc"]
		},
		syr: {
			sc: ["Syrc"]
		},
		szl: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"]
		},
		ta: {
			sc: ["Taml"]
		},
		tdd: {
			sc: ["Tale"]
		},
		te: {
			sc: ["Telu"]
		},
		th: {
			sc: ["Thai"]
		},
		ti: {
			sc: ["Ethi"]
		},
		tig: {
			sc: ["Ethi"]
		},
		tl: {
			sc: ["Latn", "Tglg"]
		},
		tmr: {
			sc: ["Hebr"]
		},
		tr: {
			g: ["s", "p"],
			alt: 1
		},
		tts: {
			sc: ["Thai"]
		},
		udi: {
			sc: ["Cyrl", "Latn", "Armn", "Geor"]
		},
		ug: {
			sc: ["Arab"],
			wsc: ["ug-Arab"]
		},
		uga: {
			sc: ["Ugar"]
		},
		uk: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p", "impf", "pf"],
			sc: ["Cyrl"],
			trauto: 1
		},
		ur: {
			g: ["m", "f", "m-p", "f-p"],
			sc: ["Arab"],
			wsc: ["ur-Arab"]
		},
		vec: {
			g: ["m", "f", "m-p", "f-p"]
		},
		vls: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"]
		},
		wuu: {
			sc: ["Hani"]
		},
		xae: {
			sc: ["Ital"]
		},
		xcr: {
			sc: ["Cari"]
		},
		xfa: {
			sc: ["Ital"]
		},
		xh: {
			alt: 1,
			nclass: 1
		},
		xlc: {
			sc: ["Lyci"]
		},
		xld: {
			sc: ["Lydi"]
		},
		xlu: {
			sc: ["Xsux"]
		},
		xmf: {
			sc: ["Geor"]
		},
		xno: {
			g: ["m", "f", "m-p", "f-p"]
		},
		xrr: {
			sc: ["Ital"]
		},
		xst: {
			sc: ["Ethi"]
		},
		xum: {
			sc: ["Ital"]
		},
		xve: {
			sc: ["Ital"]
		},
		xvo: {
			sc: ["Ital"]
		},
		yi: {
			g: ["m", "f", "n", "m-p", "f-p", "n-p"],
			sc: ["Hebr"]
		},
		yua: {
			g: ["s", "p"],
			alt: 1
		},
		yue: {
			sc: ["Hani"]
		},
		zgh: {
			sc: ["Tfng"],
			trauto: 1
		},
		zh: {
			sc: ["Hani"],
			trauto: 1
		},
		"zh-classical": {
			sc: ["Hani"],
			trauto: 1
		},
		"zh-yue": {
			sc: ["Hani"],
			trauto: 1
		},
		zu: {
			alt: 1,
			nclass: 1
		}
	};

	var clean = {
		afrikaans: "af",
		aimara: "ay",
		akan: "ak",
		"albanès": "sq",
		alemany: "de",
		"anglès": "en",
		"aragonès": "an",
		armeni: "hy",
		basc: "eu",
		castella: "es",
		"còrnic": "kw",
		cors: "co",
		croat: "hr",
		eslovac: "sk",
		"eslovè": "sl",
		espanyol: "es",
		esperanto: "eo",
		"estonià": "et",
		ewe: "ee",
		ful: "ff",
		gallec: "gl",
		grec: "el",
		hebreu: "he",
		hindi: "hi",
		idix: "yi",
		ido: "io",
		indonesi: "id",
		inuktitut: "iu",
		interlingua: "ia",
		interlingue: "ie",
		inupiaq: "ik",
		ioruba: "yo",
		"irlandès": "ga",
		jiddisch: "yi",
		kurd: "ku",
		lao: "lo",
		"letó": "lv",
		"lituà": "lt",
		"llatí": "la",
		macedoni: "mk",
		malai: "ms",
		malgaix: "mg",
		"maltès": "mt",
		manx: "gv",
		maori: "mi",
		noruec:"no", nynorsk: "nn", bokmal: "nb",
		"occità": "oc",
		paixtu: "ps",
		pali: "pi",
		panjabi: "pa",
		persa: "fa",
		"portuguès": "pt",
		"romanès": "ro",
		rus: "ru",
		sard: "sc",
		serbi: "sr",
		serbocroat: "sh",
		suec: "sv",
		"tahitià": "ty",
		tai: "th",
		turc: "tr",
		turcman: "tk",
		txec: "cs",
		vietnamita: "vi",
		volapuk: "vo"
	};
	// }}}

	// FIXME: merge into above
	var nesting = {
	};

	var stripArabicDiacritics = { strip: "\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652" };
	var stripGraveAndAcute = { strip: "\u0300\u0301" };
	var fullToHalfWidthNumbers = {
		from: "0123456789",
		to: "0123456789"
	};
	// These should reflect the replacements made in [[Module:languages]], but should not necessarily be equal.
	var diacriticStrippers = {
		ang: {
			from: "ĀāǢǣĊċĒēĠġĪīŌōŪūȲȳ",
			to: "AaÆæCcEeGgIiOoUuYy",
			strip: "\u0304\u0307",
		}, //macron and above dot
		ar: stripArabicDiacritics,
		aao: stripArabicDiacritics,
		acm: stripArabicDiacritics,
		acx: stripArabicDiacritics,
		adf: stripArabicDiacritics,
		aeb: stripArabicDiacritics,
		afb: stripArabicDiacritics,
		ajp: stripArabicDiacritics,
		apc: stripArabicDiacritics,
		apd: stripArabicDiacritics,
		arq: stripArabicDiacritics,
		ary: stripArabicDiacritics,
		arz: stripArabicDiacritics,
		fa: stripArabicDiacritics,
		ps: stripArabicDiacritics,
		sd: stripArabicDiacritics,
		ur: stripArabicDiacritics,
		chl: {
			from: "ÁáÉéÍíÓóÚú",
			to: "AaEeIiOoUu",
			strip: "\u0304",
		}, //acute accent
		he: {
			strip: "\u05B0\u05B1\u05B2\u05B3\u05B4\u05B5\u05B6\u05B7\u05B8\u05B9\u05BA\u05BB\u05BC\u05BD\u05BF\u05C1\u05C2",
			from: "-'\"",
			to: "־׳״",
		},
		la: {
			from: "ĀāĒēĪīŌōŪūȲȳ",
			to: "AaEeIiOoUuYy",
			strip: "\u0304",
		}, //macron
		lt: {
			from: "áãàéẽèìýỹñóõòúù",
			to: "aaaeeeiyynooouu",
			strip: "\u0340\u0301\u0303",
		},
		nci: {
			from: "ĀāĒēĪīŌōŪūȲȳ",
			to: "AaEeIiOoUu",
			strip: "\u0304",
		}, //macron
		//strip ́ and ̀ on Cyrillic Slavic languages, Serbo-Croatian has a longer list
		ru: stripGraveAndAcute,
		uk: stripGraveAndAcute,
		be: stripGraveAndAcute,
		bg: stripGraveAndAcute,
		orv: stripGraveAndAcute,
		cu: stripGraveAndAcute,
		rue: stripGraveAndAcute,
		mk: stripGraveAndAcute,
		sh: {
			from: "ȀȁÀàȂȃÁáĀāȄȅÈèȆȇÉéĒēȈȉÌìȊȋÍíĪīȌȍÒòȎȏÓóŌōȐȑȒȓŔŕȔȕÙùȖȗÚúŪūѝӣ",
			to: "AaAaAaAaAaEeEeEeEeEeIiIiIiIiIiOoOoOoOoOoRrRrRrUuUuUuUuUuии",
			strip: "\u030F\u0300\u0311\u0301\u0304",
		},
		sl: {
			from: "áÁàÀâÂȃȂȁȀéÉèÈêÊȇȆȅȄíÍìÌîÎȋȊȉȈóÓòÒôÔȏȎȍȌŕŔȓȒȑȐúÚùÙûÛȗȖȕȔệỆộỘẹẸọỌəł",
			to: "aAaAaAaAaAeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOrRrRrRuUuUuUuUuUeEoOeEoOel",
			strip: "\u0301\u0300\u0302\u0311\u030f\u0323",
		},
		kk: stripGraveAndAcute,
		ky: stripGraveAndAcute,
		tg: stripGraveAndAcute,
		sa: {
			strip: "ः",
		},
		/** visarga **/
		bo: {
			strip: "།",
		},
		/** shad **/
		tr: {
			from: "ÂâÛû",
			to: "AaUu",
			strip: "\u0302",
		},
		ja: fullToHalfWidthNumbers,
		cmn: fullToHalfWidthNumbers,
		yue: fullToHalfWidthNumbers,
		nan: fullToHalfWidthNumbers,
		ko: fullToHalfWidthNumbers,
		zu: {
			strip_init_hyphen: true,
		}
	};
	
	function stringOrNull(val) {
		return typeof val == "string" ? val : null;
	}
	
	function makeMap(obj) {
		var from = stringOrNull(obj.from);
		var to = stringOrNull(obj.to);
		var strip = stringOrNull(obj.strip);
		var map = {};
		if (from && to) {
			for (var i = 0; i < from.length; i++) {
				map[from.charAt(i)] = to.charAt(i);
			}
		}
		if (strip) {
			for (var ii = 0; ii < strip.length; ii++) {
				map[strip.charAt(ii)] = "";
			}
		}
		return map;
	}
	
	/** letters and number 1 are used instead of palochka **/
	var palochkaCorrections = {
		from: "Il1",
		to: "ӏӏӏ"
	};
	
	// 
	var arabicYa = "ي"; // Arabic letter yāʾ (U+064A ARABIC LETTER YEH)
	var arabicKaf = "ك"; // Arabic letter kāf (U+0643 ARABIC LETTER KAF)
	var farsiYe = "ی"; // Persian letter ye (U+06CC ARABIC LETTER FARSI YEH)
	var farsiKaf = "ک"; // Persian letter kâf (U+06A9 ARABIC LETTER KEHEH)
	var alifMaqsura = "ى"; // Arabic letter ʾalif maqṣūra (U+0649 ARABIC LETTER ALEF MAKSURA)
	
	// These replacements will be applied when a word is submitted.
	var orthographicalCorrections = {
		// Replace grave accents with acute accents for translations
		// into Bulgarian per Wiktionary policy
		bg: {
			map: { "\u0300": "\u0301", "Ѐ": "Е́", "Ѝ": "И́", "ѐ": "е́", "ѝ": "и́" },
		},
		abq: palochkaCorrections,
		ady: palochkaCorrections,
		av: palochkaCorrections,
		ce: palochkaCorrections,
		dar: palochkaCorrections,
		inh: palochkaCorrections,
		kbd: palochkaCorrections,
		lbe: palochkaCorrections,
		lez: palochkaCorrections,
		tab: palochkaCorrections,
		/** Roman to Cyrillic**/
		cv: {
			from: "ĂăĔĕÇçŸÿ",
			to: "ӐӑӖӗҪҫӲӳ",
		},
		kv: {
			from: "ÖöIi",
			to: "ӦӧІі",
		},
		koi: {
			from: "ÖöIi",
			to: "ӦӧІі",
		},
		kpv: {
			from: "ÖöIi",
			to: "ӦӧІі",
		},
		os: {
			from: "Ææ",
			to: "Ӕӕ",
		},
		/* Obsolete or incorrectly used letters */
		mn: {
			from: "ЄєѲѳЇїVv",
			to: "ӨөӨөҮүҮү",
			strip: "\u0300\u0301",
		},
		/* cedilla to comma below */
		ro: {
			from: "ŞŢşţ",
			to: "ȘȚșț",
		},
		/** ʻ is a standard symbol in Uzbek but is often replaced with ' or ` **/
		uz: {
			from: "'`",
			to: "ʻʻ",
		},
		/** commonly misspelled Persian letters (Arabic instead of Persian) (to be expanded) **/
		fa: {
			from: arabicKaf + arabicYa + alifMaqsura,
			to: farsiKaf + farsiYe + farsiYe,
		},
		ur: {
			from: arabicKaf + arabicYa + alifMaqsura,
			to: farsiKaf + farsiYe + farsiYe,
		},		
		/** commonly misspelled Arabic letters (Persian instead of Arabic) (to be expanded) **/
		ar: {
			from: farsiKaf + farsiYe,
			to: arabicKaf + arabicYa,
		},
		ota: {
			from: farsiKaf + arabicYa + alifMaqsura,
			to: arabicKaf + farsiYe + farsiYe,
		},
		ps: {
			from: arabicKaf,
			to: farsiKaf,
		},
		/** some letters are considered more standard (to be expanded) **/
		cu: {
			from: "ыѹ",
			to: "ꙑу",
		},
		/** some letters are considered more standard (to be expanded) **/
		orv: {
			from: "ыѹ",
			to: "ꙑу",
		},
		/** obsolete letters **/
		ab: {
			from: "ҔҕҦҧ",
			to: "ӶӷԤԥ",
		},
	};
	
	//Given a language code return a default script code.
	this.guessScript = function(lang) {
		var scripts = this.GetScriptsByLangCode(lang);
		if (scripts && scripts.length > 0) return scripts[0];
		else return false;
	};
	
	//Given a language code return script codes.
	this.GetScriptsByLangCode = function(lang) {
		if (metadata[lang]) {
			if (metadata[lang].wsc) {
				return metadata[lang].wsc;
			}
			if (metadata[lang].sc) {
				return metadata[lang].sc;
			}
		}

		return [];
	};
	
	this.HasAutomaticTransliteration = function (lang) {
		if (metadata[lang] && metadata[lang].trauto) return true;
		else return false;
	};
	
	// In a given language, would we expect a translation of the title to have the capitalisation
	// of word?
	this.expectedCase = function(lang, title, word) {
		if (metadata[lang] && metadata[lang].allowCaps)
			return true;

		if (title.substr(0, 1).toLowerCase() != title.substr(0, 1))
			return true;

		return word.substr(0, 1).toLowerCase() == word.substr(0, 1);
	};

	//Returns a string of standard gender letters (mfnc) or an empty string
	this.getGenders = function(lang) {
		if (metadata[lang])
			return metadata[lang].g;
	};

	//Returns a string of standard noun class numbers or an empty string
	this.hasNounClasses = function(lang) {
		if (metadata[lang])
			return metadata[lang].nclass;
	};

	//Returns true if the specified lang uses optional vowels or diacritics
	this.needsRawPageName = function(lang) {
		if (metadata[lang])
			return metadata[lang].alt && !diacriticStrippers[lang];
	};
	
	function applyMap(map, str) {
		var input = str.split("");
		var output = "";

		for (var i = 0; i < input.length; i++) {
			var char = input[i];
			var repl = map[char];
			output += repl ? repl : char;
		}
		return output;
	}
	
	this.applyOrthographicalCorrections = function(lang, word) {
		var corrections = orthographicalCorrections[lang];
		if (corrections) {
			var map = corrections.map ? corrections.map : makeMap(corrections);
			return applyMap(map, word);
		}
		return word;
	};

	// Computes the raw page name by removing diacritics (for Latin, etc.)
	this.computeRawPageName = function(lang, word) {
		var stripper = diacriticStrippers[lang];
		if (stripper) {
			var map = makeMap(stripper);
			var output = applyMap(map, word);

			if (stripper.strip_init_hyphen && output.length > 0 && output.charAt(0) == '-')
				output = output.substr(1);

			return output;
		}
	};

	//Given user input, return a language code. Normalises ISO 639-1 codes and names to 639-3.
	this.cleanLangCode = function(lang) {
		var key = lang.toLowerCase().replace(' ', '');
		if (clean[key])
			return clean[key];
		else
			return lang;
	};

	// Get the nesting for a given sub-language
	this.getNested = function(lang) {
		if (nesting[lang])
			return nesting[lang];
		else
			return "";
	};

	function temporalSortKey(langname) {
		return langname.replace(/^(Ancient|Classical|Old|Middle|Early Modern|Modern) (.*)/, function(m, modifier, name) {
			return ({
				Ancient: 0,
				Old: 1,
				Middle: 2,
				"Early Modern": 3,
				Modern: 4
			})[modifier] + name;
		});
	}

	// For enforcing an ordering on nested languages.
	this.nestsBefore = function(a, b) {
		return temporalSortKey(a) < temporalSortKey(b);
	};

	this.getScripts = function(lang) {
		var scripts = this.GetScriptsByLangCode(lang) || [];
		return scripts;
	};
};
//</nowiki>