45,337
edits
No edit summary |
No edit summary |
||
(39 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
[[Module:utilities]] | [[Module:utilities]] | ||
[[Module:string]] | [[Module:string]] | ||
]=] | ]=] | ||
Line 18: | Line 17: | ||
-- of the same name. | -- of the same name. | ||
local usub = mw.ustring.sub | local usub = mw.ustring.sub | ||
local table_insert = table.insert | local table_insert = table.insert | ||
Line 65: | Line 63: | ||
if target:sub(1, 1) == "/" then | if target:sub(1, 1) == "/" then | ||
return ":" .. target | return ":" .. target | ||
end | end | ||
Line 90: | Line 75: | ||
or langCode:find("^sj[dektu]$") then | or langCode:find("^sj[dektu]$") then | ||
if link.display and link.display:find("'") then | if link.display and link.display:find("'") then | ||
elseif link.target and link.target:find("'") then | elseif link.target and link.target:find("'") then | ||
end | end | ||
end | end | ||
Line 130: | 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 160: | Line 144: | ||
if not prefixes[prefix] then | if not prefixes[prefix] then | ||
if not link.fragment and lang:getCode() ~= "und" then | if not link.fragment and lang:getCode() ~= "und" then | ||
if id then | if id then | ||
link.fragment = require("Module:utilities").make_id(lang, id) | link.fragment = require("Module:utilities").make_id(lang, id) | ||
elseif not find(link.target, "^Appendix:") | elseif not mw.ustring.find(link.target, "^Appendix:") | ||
and not find(link.target, "^Reconstruction:") then | and not mw.ustring.find(link.target, "^Reconstruction:") then | ||
link.fragment = lang:getCanonicalName() | link.fragment = lang:getCanonicalName() | ||
end | end | ||
Line 180: | Line 158: | ||
end | end | ||
return "[[" | return "[[" .. (link.nocont and "wikt:" or "Contionary:") .. link.target .. "#" .. lang:getCanonicalName() .. "|" .. link.display .. "]]" | ||
end | end | ||
Line 226: | Line 204: | ||
-- then act as if each link begins with * | -- then act as if each link begins with * | ||
local allReconstructed = false | local allReconstructed = false | ||
if text:find("^*.") then | |||
allReconstructed = true | |||
end | |||
-- Do we have embedded wikilinks? | -- Do we have embedded wikilinks? | ||
if text:find("[[", nil, true) then | if text:find("[[", nil, true) then | ||
if data.alt then | if data.alt then | ||
mw.log("(from Module:links)", "text with embedded wikilinks:", text, | mw.log("(from Module:links)", "text with embedded wikilinks:", text, | ||
"ignored alt:", data.alt, "lang:", data.lang:getCode()) | "ignored alt:", data.alt, "lang:", data.lang:getCode()) | ||
Line 241: | Line 218: | ||
if data.id then | if data.id then | ||
mw.log("(from Module:links)", "text with embedded wikilinks:", text, | mw.log("(from Module:links)", "text with embedded wikilinks:", text, | ||
"ignored id:", data.id, "lang:", data.lang:getCode()) | "ignored id:", data.id, "lang:", data.lang:getCode()) | ||
Line 251: | Line 227: | ||
-- This makes the wikilink tag redundant. | -- This makes the wikilink tag redundant. | ||
if text:find("^%[%[[^%[%]]+%]%]$") then | if text:find("^%[%[[^%[%]]+%]%]$") then | ||
else | else | ||
local temp = text:gsub("^%[%[(.+)%]%]$", "%1") | local temp = text:gsub("^%[%[(.+)%]%]$", "%1") | ||
temp = temp:gsub("%]%], %[%[", "|") | temp = temp:gsub("%]%], %[%[", "|") | ||
end | end | ||
end | end | ||
Line 280: | Line 251: | ||
else | else | ||
-- There is no embedded wikilink, make a link using the parameters. | -- There is no embedded wikilink, make a link using the parameters. | ||
text = makeLangLink({ target = text, display = data.alt }, data.lang, data.id, allow_self_link) | text = makeLangLink({ target = text, display = data.alt, nocont = data.nocont}, data.lang, data.id, allow_self_link) | ||
end | end | ||
Line 330: | Line 301: | ||
if data.genders and #data.genders > 0 then | if data.genders and #data.genders > 0 then | ||
local m_gen = require("Module: | local m_gen = require("Module:getn") | ||
table_insert(output, " " .. m_gen.format_list(data.genders, data.lang)) | table_insert(output, " " .. m_gen.format_list(data.genders, data.lang)) | ||
end | end | ||
Line 400: | 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 407: | Line 378: | ||
-- Track uses of sc parameter | -- Track uses of sc parameter | ||
local best = require("Module:scripts").findBestScript(data.alt or data.term, data.lang) | local best = require("Module:scripts").findBestScript(data.alt or data.term, data.lang) | ||
end | end | ||
Line 454: | 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 483: | 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 | if not data.tr 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 516: | 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 | ||
Line 523: | Line 494: | ||
return table_concat(output) .. table_concat(categories) | return table_concat(output) .. table_concat(categories) | ||
end | end | ||
--[[ Strips links: deletes category links, | --[[ Strips links: deletes category links, |