มอดูลนี้เป็นส่วนหนึ่งของ วิกิพจนานุกรม:สคริปต์แมว ๆ ซึ่งทำงานร่วมกับจาวาสคริปต์


local export = {}

-- restored from Module:languages
function export.getByName(name, errorIfInvalid)

	local byName = mw.loadData("Module:languages/by name")
	local code = byName.all and byName.all[name] or byName[name]
	
	if not code then
		if errorIfInvalid then
			error("The language name \"" .. name .. "\" is not valid. See [[Wiktionary:List of languages]].")
		else
			return nil
		end
	end
	
	return require("Module:languages").getByCode(code)

end

function export.getCategoryNameFromAlias(frame)

	local args = frame.args
	local langname = args[1] or error("Language name has not been specified. Please pass parameter 1 to the module invocation.")

	lang = export.getByName(langname, false)
	if lang then
		langname2 = lang:getCanonicalName()
		if langname2 ~= langname then
			return lang:getCategoryName()
		else
			return langname2
		end
	else
		return langname
	end

end

return export