Module:links: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 146: Line 146:
local prefix = target:gsub("^:*(.-):.*", ulower)
local prefix = target:gsub("^:*(.-):.*", ulower)
if (
if (
mw.loadData("Module:data/namespaces")[prefix] or
load_data("Module:data/namespaces")[prefix] or
mw.loadData("Module:data/interwikis")[prefix]
load_data("Module:data/interwikis")[prefix]
) then
) then
return ":" .. target:gsub("^:+", ""), nil, {}
return ":" .. target:gsub("^:+", ""), nil, {}
Line 158: Line 158:
local reconstructed, escaped
local reconstructed, escaped
if not plain then
if not plain then
target = target:gsub("^%*(.)", "%1")
target, reconstructed = target:gsub("^%*(.)", "%1")
end
end
reconstructed = lang:hasType("reconstructed") and 1 or 0
conlang = lang:hasType("conlang") and 1 or 0
target, escaped = target:gsub("^(\\-)\\%*", "%1*")
target, escaped = target:gsub("^(\\-)\\%*", "%1*")


Line 185: Line 183:
if target:sub(1, 1) == "/" then
if target:sub(1, 1) == "/" then
return ":" .. target
return ":" .. target
elseif target:find("^Reconstruction:") then
elseif target:find("^Reconstruction:") then
return "wikt:" .. target
return "wikt:" .. target
 
-- Link to appendix for reconstructed terms and terms in appendix-only languages. Plain links interpret * literally, however.
-- Link to appendix for reconstructed terms and terms in appendix-only languages. Plain links interpret * literally, however.
elseif reconstructed == 1 then
elseif reconstructed == 1 then
Line 196: Line 195:
end
end
-- Reconstructed languages and substrates require an initial *.
-- Reconstructed languages and substrates require an initial *.
elseif (reconstructed or lang:getFamilyCode() == "qfa-sub") then
elseif lang:hasType("reconstructed") or lang:getFamilyCode() == "qfa-sub" then
local check = target:match("^:*([^:]*):")
local check = target:match("^:*([^:]*):")
check = check and ulower(check)
check = check and ulower(check)
if (
if (
mw.loadData("Module:data/namespaces")[check] or
load_data("Module:data/namespaces")[check] or
mw.loadData("Module:data/interwikis")[check]
load_data("Module:data/interwikis")[check]
) then
) then
return target
return target
else
else
error("The specified language " .. lang:getCanonicalName()
--[[error("The specified language " .. lang:getCanonicalName()
.. " is unattested, while the given term does not begin with '*' to indicate that it is reconstructed.")
.. " is unattested, while the given term does not begin with '*' to indicate that it is reconstructed.")]]
return "*" .. target
end
end


elseif lang:hasType("appendix-constructed") then
elseif lang:hasType("appendix-constructed") then
target = "wikt:Appendix:" .. lang:getCanonicalName() .. "/" .. target
target = "wikt:Appendix:" .. lang:getFullName() .. "/" .. target
end
end


Navigation menu