Bu modul uchun Modul:etymology languages/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}

local EtymologyLanguage = {}


function EtymologyLanguage:getCode()
	return self._code
end


function EtymologyLanguage:getCanonicalName()
	return self._rawData.canonicalName
end


function EtymologyLanguage:getOtherNames()
	return self._rawData.otherNames or {}
end


--function EtymologyLanguage:getAllNames()
--	return self._rawData.names
--end


function EtymologyLanguage:getCategoryName()
	return self:getCanonicalName()
end


function EtymologyLanguage:getType()
	return "etymology language"
end


function EtymologyLanguage:getParentCode()
	return self._rawData.parent
end


function EtymologyLanguage:getWikipediaArticle()
	return self._rawData.wikipedia_article or self._rawData.canonicalName
end


function EtymologyLanguage:toJSON()
	local ret = {
		canonicalName = self:getCanonicalName(),
		categoryName = self:getCategoryName(),
		code = self._code,
		otherNames = self:getOtherNames(),
		parent = self._rawData.parent,
		type = self:getType(),
		}
	
	return require("Module:JSON").toJSON(ret)
end


function EtymologyLanguage:getRawData()
	return self._rawData
end


EtymologyLanguage.__index = EtymologyLanguage


function export.makeObject(code, data)
	return data and setmetatable({ _rawData = data, _code = code }, EtymologyLanguage) or nil
end


function export.getByCode(code)
	return export.makeObject(code, mw.loadData("Module:etymology languages/data")[code])
end


return export