45,333
edits
No edit summary |
No edit summary |
||
(34 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
[[Module:utilities]] | [[Module:utilities]] | ||
[[Module:string]] | [[Module:string]] | ||
]=] | ]=] | ||
Line 64: | Line 63: | ||
if target:sub(1, 1) == "/" then | if target:sub(1, 1) == "/" then | ||
return ":" .. target | return ":" .. target | ||
end | end | ||
Line 89: | 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 129: | 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 159: | 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 | ||
Line 179: | Line 158: | ||
end | end | ||
return "[[Contionary:" .. link.target .. "|" .. link.display .. "]]" | return "[[" .. (link.nocont and "wikt:" or "Contionary:") .. link.target .. "#" .. lang:getCanonicalName() .. "|" .. link.display .. "]]" | ||
end | end | ||
Line 232: | Line 211: | ||
-- 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 244: | 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 254: | 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 283: | 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 333: | 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 403: | 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 410: | 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 457: | 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 486: | 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 519: | 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 526: | 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, |