Module:also: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 4: Line 4:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs


function export.codify(text) --removes diacritics and non-alphanumeric characters, converts to upper case
function codify(text) --removes diacritics and non-alphanumeric characters, converts to upper case
text = mw.ustring.toNFC(text)
text = mw.ustring.toNFC(text)
text = mw.ustring.gsub(text,"[ÁÀÂÄǍĂĀÃÅĄ]","A")
text = mw.ustring.gsub(text,"[ÁÀÂÄǍĂĀÃÅĄ]","A")
Line 70: Line 70:
else -- auto mode
else -- auto mode
local here = args["test"] or mw.title.getCurrentTitle().subpageText
local here = args["test"] or mw.title.getCurrentTitle().subpageText
local data = mw.loadData("Module:also/data")
local termlist = mw.loadData("Module:also/data")
local data = {}
for _, term in ipairs(termlist) do -- sorts data into "codes"
local code = codify(term)
if data[code] == nil then data[code] = {} end
table.insert(data[code], term)
end
local here_key = ""
local here_key = ""
Line 79: Line 87:
if page == here then
if page == here then
here_key = key
here_key = key
mw.log("key found: " .. here_key)
break
break
end
end
Line 89: Line 96:
if here_key == "" then
if here_key == "" then
mw.log("no key match")
local toAdd = false
local toAdd = false
local check_key = export.codify(here)
local check_key = codify(here)
for key, _ in pairs(data) do
for key, _ in pairs(data) do
Line 101: Line 107:
if toAdd then
if toAdd then
return "possibility found: " .. check_key
mw.log("possibility found: " .. check_key)
return "<div class=\"noprint maintenance-box maintenance-box-yellow\" style=\"background:#FFFFDD; width:{{{width|90}}}%; margin: 0.75em auto; border:1px dashed #888822; padding: 0.25em; \">\n{|\n| rowspan=\"2\" | [[File:Nuvola apps important yellow.svg|50px]]\n! style=\"text-align: left;\" | Possible <code>{{[[Module:also/data|also]]}}</code> group detected!\n|-\n| Please add this term to the linked data set above.\n|}"
else
else
return ""
return ""

Navigation menu