localexport={}functionexport.exists(frame)localargs=frame.argslocallang=args[1]orerror("Language code has not been specified. Please pass parameter 1 to the module invocation.")lang=require("Module:languages").getByCode(lang)iflangthenreturn"1"elsereturn""endend-- Used by the following JS:-- * [[WT:ACCEL]]-- * [[WT:EDIT]]-- * [[WT:NEC]]functionexport.getByCode(frame)localargs=frame.argslocallangcode=args[1]orerror("Language code has not been specified. Please pass parameter 1 to the module invocation.")localitemname=args[2]orerror("Type of information to look up has not been specified. Please pass parameter 2 to the module invocation.")locallang=require("Module:languages").getByCode(langcode)ifnotlangthenerror("The language code '"..langcode.."' is not valid.")end-- The item that the caller wanted to look upifitemname=="getOtherNames"thenlocalindex=args[3];ifindex==""thenindex=nilendindex=tonumber(index)orerror("Please specify the numeric index of the desired name.")returnlang:getOtherNames()[index]or""elseifitemname=="getFamily"thenreturnlang:getFamily():getCode()elseifitemname=="getWikimediaLanguages"thenlocalindex=args[3];ifindex==""thenindex=nilendindex=tonumber(index)orerror("Please specify the numeric index of the desired language.")locallangs=lang:getWikimediaLanguages()iflangs[index]thenreturnlangs[index]:getCode()elsereturn""endelseifitemname=="getScripts"thenlocalindex=args[3];ifindex==""thenindex=nilendindex=tonumber(index)orerror("Please specify the numeric index of the desired script.")localscripts=lang:getScriptCodes()ifscripts[index]thenreturnscripts[index]elsereturn""endelseifitemname=="getAncestors"thenlocalindex=args[3];ifindex==""thenindex=nilendindex=tonumber(index)orerror("Please specify the numeric index of the desired ancestor.")localancestors=lang:getAncestors()ifancestors[index]thenreturnancestors[index]:getCode()elsereturn""endelseifitemname=="transliterate"thenlocaltext=args[3];iftext==""thentext=nilendlocalsc=args[4];ifsc==""thensc=nilendlocalmodule_override=args[5];ifmodule_override==""thenmodule_override=nilendsc=(scand(require("Module:scripts").getByCode(sc)orerror("The script code \""..sc.."\" is not valid."))ornil)returnlang:transliterate(text,sc,module_override)or""elseifitemname=="makeEntryName"thenlocaltext=args[3];iftext==""thentext=nilendreturnlang:makeEntryName(text)or""elseifitemname=="makeSortKey"thenlocaltext=args[3];iftext==""thentext=nilendreturnlang:makeSortKey(text)or""elseiflang[itemname]thenlocalret=lang[itemname](lang)iftype(ret)=="string"thenreturnretelseerror("The function \""..itemname.."\" did not return a string value.")endelseerror("Requested invalid item name \""..itemname.."\".")endendfunctionexport.getByCanonicalName(frame)localargs=frame.argslocallangname=args[1]orerror("Language name has not been specified. Please pass parameter 1 to the module invocation.")locallang=require("Module:languages").getByCanonicalName(langname)iflangthenreturnlang:getCode()elsereturn""endendfunctionexport.getByName(frame)localargs=frame.argslocallangname=args[1]orerror("Language name has not been specified. Please pass parameter 1 to the module invocation.")locallang=require("Module:languages").getByName(langname)iflangthenreturnlang:getCode()elsereturn""endendfunctionexport.makeEntryName(frame)localargs=frame.argslocallangname=args[1]orerror("Language name has not been specified. Please pass parameter 1 to the module invocation.")locallang=require("Module:languages").getByCode(langname)iflangthenreturnlang:makeEntryName(args[2])elsereturn""endendfunctionexport.getCanonicalName(frame)locallangCodeifrequire("Module:yesno")(frame.args.parent)thenlangCode=frame:getParent().args[1]elselangCode=frame.args[1]endifnotlangCodeorlangCode==""thenerror("Supply a language code in parameter 1.")endreturnmw.loadData("Module:languages/code to canonical_name")[langCode]or""endreturnexport