Module:languages: Difference between revisions

no edit summary
(Undo revision 310565 by Sware (talk))
Tag: Undo
No edit summary
Tag: Reverted
Line 599: Line 599:
end
end


--[[ If language is an etymology language, iterates through parent languages
--[==[If the language is an etymology language, this iterates through parents until a regular language or family is found, and the corresponding object is returned. If the language is a regular language, then it simply returns the language.]==]
until it finds a non-etymology language. ]]
function export.getNonEtymological()
function export.getNonEtymological(lang)
if not self._nonEtymologicalObject then
while lang:getType() == "etymology language" do
local nonEtymologicalCode = self:getNonEtymologicalCode()
local parentCode = lang:getParentCode()
if nonEtymologicalCode ~= self:getCode() then
lang = export.getByCode(parentCode)
self._nonEtymologicalObject = export.getByCode(nonEtymologicalCode, nil, nil, nil, useRequire)
or require("Module:etymology languages").getByCode(parentCode)
else
or require("Module:families").getByCode(parentCode)
self._nonEtymologicalObject = self
end
end
end
return self._nonEtymologicalObject
end
return lang
function export.getNonEtymologicalCode()
return self._nonEtymologicalCode or self:getCode()
end
 
function export.getNonEtymologicalName()
if self._nonEtymologicalName == nil then
local nonEtymological = self:getNonEtymological()
if nonEtymological then
self._nonEtymologicalName = nonEtymological:getCanonicalName()
else
self._nonEtymologicalName = false
end
end
return self._nonEtymologicalName or nil
end
end


return export
return export