Module:links: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(25 intermediate revisions by the same user not shown)
Line 63: Line 63:
if target:sub(1, 1) == "/" then
if target:sub(1, 1) == "/" then
return ":" .. target
return ":" .. target
-- Link to appendix for reconstructed terms and terms in appendix-only languages
elseif target:sub(1, 1) == "*" and #target > 1 then
if lang:getCode() == "und" then
return nil
end
target = "Reconstruction:" .. lang:getCanonicalName() .. "/" .. usub(target, 2)
elseif lang:getType() == "reconstructed" then
error("The specified language " .. lang:getCanonicalName()
.. " is unattested, while the given word is not marked with '*' to indicate that it is reconstructed")
elseif lang:getType() == "appendix-constructed" then
target = "Appendix:" .. lang:getCanonicalName() .. "/" .. target
end
end


Line 126: Line 113:
end
end
end
end
 
-- Process the target
-- Process the target
link.target = link.nocont and link.target:gsub("^%*", "Reconstruction:" .. lang:getCanonicalName() .. "/") or link.target
link.target = export.getLinkPage(link.target, lang)
link.target = export.getLinkPage(link.target, lang)


Line 383: Line 371:


-- Is there any text to show?
-- Is there any text to show?
if (data.term or data.alt) then
if (data.term or data.alt) and data.term ~= "-" then
-- Try to detect the script if it was not provided
-- Try to detect the script if it was not provided
if not data.sc then
if not data.sc then
Line 428: Line 416:
Is there at least a transliteration we can work from? ]]
Is there at least a transliteration we can work from? ]]
link = require("Module:script utilities").request_script(data.lang, data.sc)
link = require("Module:script utilities").request_script(data.lang, data.sc)
 
if link == "" or not data.tr or data.tr == "-" then
if not data.sc then
data.sc = require("Module:scripts").findBestScript(data.alt or data.term, data.lang)
else
-- Track uses of sc parameter
local best = require("Module:scripts").findBestScript(data.alt or data.term, data.lang)
end
if link == "" or link == "-" or link == "?" or not data.tr or data.tr == "-" then
-- No link to show, and no transliteration either. Show a term request.
-- No link to show, and no transliteration either. Show a term request.
local category = ""
local category = ""
Line 457: Line 452:
-- is tight. `no_check_redundant_translit` is currently set when called ultimately from
-- is tight. `no_check_redundant_translit` is currently set when called ultimately from
-- {{multitrans|...|no-check-redundant-translit=1}}.)
-- {{multitrans|...|no-check-redundant-translit=1}}.)
if not (data.tr and (
if not data.tr then
no_check_redundant_translit or
mw.loadData("Module:links/data").high_memory_entries[mw.title.getCurrentTitle().text]
)) then
local automated_tr = data.lang:transliterate(export.remove_links(data.alt or data.term), data.sc)
local automated_tr = data.lang:transliterate(export.remove_links(data.alt or data.term), data.sc)


Line 490: Line 482:
-- Link to the transliteration entry for languages that require this
-- Link to the transliteration entry for languages that require this
if data.tr and data.lang:link_tr() then
if data.tr and data.lang:link_tr() then
data.tr = export.language_link { lang = data.lang, term = data.tr }
data.tr = require("Module:script utilities").tag_text(
export.language_link({ lang = data.lang, term = data.tr, nocont = data.nocont}, allow_self_link),
data.lang, data.sc, face, class)
--data.tr = export.language_link { lang = data.lang, term = data.tr, nocont = data.nocont}
elseif data.tr then
data.tr = "''" .. data.tr .. "''"
end
end