Module:pollasena-roots: Difference between revisions
No edit summary |
No edit summary |
||
| (22 intermediate revisions by the same user not shown) | |||
| Line 19: | Line 19: | ||
end | end | ||
local function link(term,alt) | local function link(lang, term, alt) | ||
local natlang = lang:getWikidataItem() or false | |||
-- true if the language declaration has a wikidata item, a marginal amount of conlangs have it | |||
if lang:hasType("reconstructed") and not term:match("^%*") then | |||
term = "*" .. term | |||
end | |||
local data = {term = term, alt = alt or term, lang = lang, to_wikt = natlang} | |||
return require('Module:links').full_link(data, "term") | |||
end | end | ||
| Line 27: | Line 34: | ||
local a = 0 | local a = 0 | ||
if frame.args["older"] then | if frame.args["offset"] or (frame.args["old"] or frame.args["older"]) then | ||
params[ | local offset = frame.args["old"] and 1 or frame.args["older"] and 2 or tonumber(frame.args["offset"]) | ||
params[ | |||
a = | for i=1,offset do | ||
params[i] = {} | |||
end | |||
params[offset+1] = {list = true} | |||
a = offset + 1 | |||
else | else | ||
params[1] = {list = true} | params[1] = {list = true} | ||
a = 1 | a = 1 | ||
end | end | ||
-- exceptions | |||
params["and"], params["see"] = {}, {} | |||
local args = require("Module:parameters").process(frame:getParent().args, params) | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local fam, lang = m_families.getByCode(frame.args[1]), require("Module:languages").getByCode(frame.args[2]) | local fam, lang = m_families.getByCode(frame.args[1]), require("Module:languages").getByCode(frame.args[2]) | ||
local proto = fam:getProtoLanguage | local proto = fam:getProtoLanguage() | ||
local links = {}; local categories = {}; local alts = {}; | local links = {}; local categories = {}; local alts = {}; | ||
| Line 62: | Line 76: | ||
if item:match("><") then | if item:match("><") then | ||
if prefix == "a" then | if prefix == "a" then | ||
table.insert(links, link(term, arg)) | table.insert(links, link(proto, term, arg)) | ||
table.insert(alts, arg) | table.insert(alts, arg) | ||
elseif prefix == "c" then | elseif prefix == "c" then | ||
table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto .. " *" .. arg) | table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto:getCanonicalName() .. " *" .. arg) | ||
table.insert(alts, term) | table.insert(alts, term) | ||
end | end | ||
elseif prefix == "a" then | elseif prefix == "a" then | ||
table.insert(links, link(term, arg)) | table.insert(links, link(proto, term, arg)) | ||
table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto .. " *" .. term) | table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto:getCanonicalName() .. " *" .. term) | ||
table.insert(alts, arg) | table.insert(alts, arg) | ||
elseif prefix == "c" then | elseif prefix == "c" then | ||
table.insert(links, link(term)) | table.insert(links, link(proto, term)) | ||
table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto .. " *" .. arg) | table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto:getCanonicalName() .. " *" .. arg) | ||
table.insert(alts, term) | table.insert(alts, term) | ||
end | end | ||
end | end | ||
else | else | ||
table.insert(links, link(args[a][i])) | table.insert(links, link(proto, args[a][i])) | ||
table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto .. " *" .. args[a][i]) | table.insert(categories, lang:getCanonicalName() .. " terms from " .. proto:getCanonicalName() .. " *" .. args[a][i]) | ||
table.insert(alts, args[a][i]) | table.insert(alts, args[a][i]) | ||
end | end | ||
if i~=1 and links[i-1] == "-" then | if i~=1 and links[i-1] == "-" then alts[i] = links[i]:gsub("^%*","") end | ||
if i~=1 and links[i-1] ~= " " then links[i] = links[i]:gsub("%|%*%-"," | --if i~=1 and links[i-1] ~= " " then links[i] = links[i]:gsub("(%|?)%*%-","%1-") end | ||
--if i~=1 and alts[i-1]:match("%-$") then links[i] = links[i]:gsub("%|%*","|") end | --if i~=1 and alts[i-1]:match("%-$") then links[i] = links[i]:gsub("%|%*","|") end | ||
end | end | ||