Module:links: Difference between revisions

No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 337: Line 337:
end
end
end
end
 
-- Check if the term is reconstructed and remove any asterisk. Also check for anti-asterisk (!!).
-- Check if the term is reconstructed and remove any asterisk. Also check for anti-asterisk (!!).
-- Otherwise, handle the escapes.
-- Otherwise, handle the escapes.
Line 354: Line 354:
end
end
target, escaped = target:gsub("^(\\-)\\%*", "%1*")
target, escaped = target:gsub("^(\\-)\\%*", "%1*")
if reconstructed == 0 and lang:hasType("reconstructed") and not lang:hasType("conlang") then
orig_target = "*" .. target
reconstructed = 1
end


if not (sc and sc:getCode() ~= "None") then
if not (sc and sc:getCode() ~= "None") then
Line 377: Line 382:
-- Link to appendix for reconstructed terms and terms in appendix-only languages. Plain links interpret *
-- Link to appendix for reconstructed terms and terms in appendix-only languages. Plain links interpret *
-- literally, however.
-- literally, however.
if reconstructed == 1 then
if not lang:hasType("conlang") then
if lang:getFullCode() == "und" then
if lang:hasType("appendix-constructed") then
-- Return the original target as default display value. If we don't do this, we wrongly get
target = "wikt:Appendix:" .. lang:getFullName() .. "/" .. target
-- [Term?] displayed instead.
elseif reconstructed == 1 then -- asterisk found
return nil, orig_target
if lang:getFullCode() == "und" then
-- Return the original target as default display value. If we don't do this, we wrongly get
-- [Term?] displayed instead.
return nil, orig_target
end
target = "wikt:Reconstruction:" .. lang:getFullName() .. "/" .. target
elseif anti_asterisk ~= 1 and (lang:hasType("reconstructed") or lang:getFamilyCode() == "qfa-sub") then
--error("The specified language " .. lang:getCanonicalName()
--.. " is unattested, while the given term does not begin with '*' to indicate that it is reconstructed.")
orig_target = "*" .. target
else
target = target
end
end
if not lang:hasType("conlang") then
target = "Reconstruction:" .. lang:getFullName() .. "/" .. target
end
-- Reconstructed languages and substrates require an initial *.
elseif anti_asterisk ~= 1 and (lang:hasType("reconstructed") or lang:getFamilyCode() == "qfa-sub") then
error("The specified language " .. lang:getCanonicalName()
.. " is unattested, while the given term does not begin with '*' to indicate that it is reconstructed.")
elseif lang:hasType("appendix-constructed") then
target = "Appendix:" .. lang:getFullName() .. "/" .. target
else
else
target = target
target = "Contionary:" .. target
end
end
target = (lang:hasType("conlang") and "Contionary:" or "wikt:") .. target
return target, orig_target, escaped > 0
return target, orig_target, escaped > 0