Modul:etymology languages

Üdvözlöm, Ön a Modul:etymology languages szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:etymology languages szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:etymology languages szót egyes és többes számban mondani. Minden, amit a Modul:etymology languages szóról tudni kell, itt található. A Modul:etymology languages szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:etymology languages és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

This module provides etymology-only languages. It has a separate data module, Module:etymology languages/data, which stores information for etymology-only language codes.

It exports several functions that behave similarly to the ones in Module:languages: getByCode, getByCanonicalName, and makeObject. Etymology language objects returned by getByCode, getByCanonicalName, or makeObject also have many methods that behave like the methods of a language object from Module:languages: getAllNames, getAncestors, getCanonicalName, getCategoryName, getCode, getOtherNames, getRawData, getType, getWikidataItem, getWikipediaArticle, makeWikipediaLink, and toJSON. getParentCode is a unique method (distinct from getAncestors) that returns the parent value from Module:etymology languages/data.


local export = {}

local EtymologyLanguage = {}


function EtymologyLanguage:getCode()
	return self._code
end


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


function EtymologyLanguage:getOtherNames(onlyOtherNames)
	return require("Module:language-like").getOtherNames(self, onlyOtherNames)
end


function EtymologyLanguage:getAliases()
	return self._rawData.aliases or {}
end


function EtymologyLanguage:getVarieties(flatten)
	return require("Module:language-like").getVarieties(self, flatten)
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:getAncestors()
	if not self._ancestorObjects then
		self._ancestorObjects = {}
		
		for _, ancestor in ipairs(self._rawData.ancestors or {}) do
			table.insert(self._ancestorObjects, export.getByCode(ancestor) or require("Module:languages").getByCode(ancestor))
		end
	end
	
	return self._ancestorObjects
end

function EtymologyLanguage:getWikidataItem()
	return self._rawData.wikidata_item
end

function EtymologyLanguage:getWikipediaArticle()
	return self._rawData.wikipedia_article or 
		(self:getWikidataItem() and mw.wikibase and
	     mw.wikibase.sitelink(self:getWikidataItem(), 'enwiki')) or
	     self._rawData.canonicalName
end

function EtymologyLanguage:makeWikipediaLink()
	return "]"
end


function EtymologyLanguage:toJSON()
	local ret = {
		canonicalName = self:getCanonicalName(),
		categoryName = self:getCategoryName(),
		code = self._code,
		otherNames = self:getOtherNames(true),
		aliases = self:getAliases(),
		varieties = self:getVarieties(),
		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"))
end


function export.getByCanonicalName(name)
	local code = mw.loadData("Module:etymology languages/by name")
	
	if not code then
		return nil
	end
	
	return export.makeObject(code, mw.loadData("Module:etymology languages/data"))
end


return export