Module:links: Difference between revisions

No edit summary
No edit summary
 
(3 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
end
-- Return the original target as default display value. If we don't do this, we wrongly get
-- [Term?] displayed instead.
if not lang:hasType("conlang") then
return nil, orig_target
target = "Reconstruction:" .. lang:getFullName() .. "/" .. 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
-- 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
Line 445: Line 450:
-- If `no_alt_ast` is true, use pcall to catch the error which will be thrown if this is a reconstructed lang and the alt text doesn't have *.
-- If `no_alt_ast` is true, use pcall to catch the error which will be thrown if this is a reconstructed lang and the alt text doesn't have *.
if link.display == auto_display then
if link.display == auto_display then
insert(cats, lang:getFullName() .. " links with redundant alt parameters")
else
else
local ok, check
local ok, check
Line 453: Line 457:
ok = true
ok = true
check = export.get_link_page(orig_display, lang, sc, plain)
check = export.get_link_page(orig_display, lang, sc, plain)
end
if ok and link.target == check then
insert(cats, lang:getFullName() .. " links with redundant target parameters")
end
end
end
end
Line 664: Line 665:
end
end
term, alt = new_term, new_alt
term, alt = new_term, new_alt
if cats then
if not (srwc and srwc(term, alt)) then
insert(cats, lang:getFullName() .. " links with redundant wikilinks")
end
end
end
end
end
end
Line 1,233: Line 1,229:
if automated_tr or data.tr_fail then
if automated_tr or data.tr_fail then
local manual_tr = data.tr[1]
local manual_tr = data.tr[1]
if manual_tr then
if (export.remove_links(manual_tr) == export.remove_links(automated_tr)) and (not data.tr_fail) then
insert(cats, lang:getFullName() .. " terms with redundant transliterations")
end
end
if (not manual_tr) or lang:overrideManualTranslit(data.sc[1]) then
if (not manual_tr) or lang:overrideManualTranslit(data.sc[1]) then