Modul:etymology
Bu modul uchun Modul:etymology/doc nomli hujjat sahifasini yaratishingiz mumkin
local export = {}
function export.format_etyl(tili, source, sort_key)
local info
if source:getCode() == "va" then
info = {
display = "undetermined",
cat_name = "other languages"}
elseif source:getType() == "etymology language" then
info = {
display = "[[w:" .. source:getWikipediaArticle() .. "|" .. source:getCanonicalName() .. "]]",
cat_name = source:getCanonicalName()}
elseif source:getType() == "family" then
info = {
display = "[[w:" .. source:getCategoryName() .. "|" .. source:getCanonicalName() .. "]]",
cat_name = source:getCategoryName()}
else
info = {
display = "[[w:" .. source:getWikipediaArticle() .. "|" .. source:getCanonicalName() .. "]]",
cat_name = source:getCanonicalName()}
end
-- Add the categories, but only if there is a current language
local categories = ""
if tili then
local m_utilities = require("Module:utilities")
categories = {}
if tili:getCode() == source:getCode() then
categories = m_utilities.format_categories({tili:getCanonicalName() .. " twice-borrowed terms"}, tili, sort_key)
else
categories = m_utilities.format_categories({tili:getCanonicalName() .. " terms derived from " .. info.cat_name}, tili, sort_key)
end
end
return "<span class=\"etyl\">" .. info.display .. categories .. "</span>"
end
function export.format_derived(tili, sc, source, term, alt, id, annotations, sort_key)
local linktarget = source
if source:getType() == "etymology language" then
linktarget = require("Module:tili").getByCode(source:getParentCode())
end
local link = ""
if term or alt or id or annotations.tr or annotations.gloss or annotations.pos or annotations.lit then
link = " " .. require("Module:links").full_link(term, alt, linktarget, sc, "term", id, annotations, true)
end
return export.format_etyl(tili, source, sort_key) .. link
end
function export.format_inherited(tili, sc, source, term, alt, id, annotations, sort_key)
local linktarget = source
if source:getType() == "etymology language" then
linktarget = require("Module:tili").getByCode(source:getParentCode())
end
if not tili:hasAncestor(linktarget) and mw.title.getCurrentTitle().nsText ~= "Andoza" then
error(source:getCanonicalName() .. " is not an ancestor of " .. tili:getCanonicalName() .. ".")
end
local link = ""
if term or alt or id or annotations.tr or annotations.gloss or annotations.pos or annotations.lit then
link = " " .. require("Module:links").full_link(term, alt, linktarget, sc, "term", id, annotations, true)
end
local categories = require("Module:utilities").format_categories({tili:getCanonicalName() .. " terms inherited from " .. source:getCanonicalName()}, tili, sort_key)
return export.format_etyl(nil, source, sort_key) .. link .. categories
end
function export.format_borrowed(tili, sc, source, term, alt, id, annotations, sort_key, nocap, notext, learned)
local linktarget = source
if source:getType() == "etymology language" then
linktarget = require("Module:tili").getByCode(source:getParentCode())
end
local text = ""
if learned then
text = "[[learned borrowing|" .. (nocap and "l" or "L") .. "earned borrowing]] from "
else
text = "[[Appendix:Glossary#loanword|" .. (nocap and "b" or "B") .. "orrowing]] from "
end
local link = ""
if term or alt or id or annotations.tr or annotations.gloss or annotations.pos or annotations.lit then
link = " " .. require("Module:links").full_link(term, alt, linktarget, sc, "term", id, annotations, true)
end
local categories = require("Module:utilities").format_categories({tili:getCanonicalName() .. (learned and " learnedly" or "") .. " borrowed terms"}, tili, sort_key)
return (notext and "" or text) .. export.format_etyl(tili, source, sort_key) .. link .. categories
end
return export