Editing Module:D'ni Tools
From Guild of Archivists
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
local args = {} | local args = {} | ||
local origArgs | local origArgs | ||
local output = '' | local output = '' | ||
-- Local Functions | -- Local Functions | ||
local function dnifont2ots(str) | local function dnifont2ots(str) | ||
Line 173: | Line 48: | ||
["O"] = "ó", | ["O"] = "ó", | ||
["c"] = "ç", | ["c"] = "ç", | ||
["E"] = " | ["E"] = "i", | ||
["A"] = "é", | ["A"] = "é", | ||
["U"] = "ú", | ["U"] = "ú", | ||
Line 190: | Line 65: | ||
local function parseDniWord(input | local function parseDniWord(input) | ||
local output | local output | ||
local word = mw.text.trim(input) | local word = mw.text.trim(input) | ||
Line 206: | Line 79: | ||
suffix = prefix | suffix = prefix | ||
end | end | ||
if (word == '') then | if (word == '') then | ||
Line 216: | Line 88: | ||
elseif (first == '-') then | elseif (first == '-') then | ||
output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | ||
elseif (last == '-') then | elseif (last == '-') then | ||
output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix | output = prefix..'[[Dictionary:'..word..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix | ||
elseif (first == '.' or first == '!' or first == '?' or first == ',') then | elseif (first == '.' or first == '!' or first == '?' or first == ',') then | ||
output = first..prefix..'[[Dictionary:'..mw.ustring.sub(word,2,-1)..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | output = first..prefix..'[[Dictionary:'..mw.ustring.sub(word,2,-1)..'|'..mw.ustring.sub(word,2,-1)..']]'..suffix | ||
elseif (last == ',') then | elseif (last == ',') then | ||
output = prefix..'[[Dictionary:'..mw.ustring.sub(word,1,-2)..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix..last | output = prefix..'[[Dictionary:'..mw.ustring.sub(word,1,-2)..'|'..mw.ustring.sub(word,1,-2)..']]'..suffix..last | ||
else | else | ||
output = prefix..'[[Dictionary:'..word..'|'..word..']]'..suffix | output = prefix..'[[Dictionary:'..word..'|'..word..']]'..suffix | ||
end | end | ||
return output | return output | ||
end | end | ||
Line 250: | Line 109: | ||
else | else | ||
origArgs = frame.args | origArgs = frame.args | ||
end | end | ||
for word in ipairs(origArgs) do | for word in ipairs(origArgs) do | ||
output = output..parseDniWord(origArgs[word] | output = output..parseDniWord(origArgs[word]) | ||
end | end | ||
return output | return output | ||
end | end | ||
function p.dnifont2ots(frame) | function p.dnifont2ots(frame) | ||
-- If called via #invoke, use the args passed into the invoking template. | -- If called via #invoke, use the args passed into the invoking template. | ||
-- Otherwise, for testing purposes, assume args are being passed directly in. | -- Otherwise, for testing purposes, assume args are being passed directly in. | ||
Line 311: | Line 124: | ||
origArgs = frame:getParent().args | origArgs = frame:getParent().args | ||
else | else | ||
origArgs = frame | origArgs = frame | ||
end | end | ||
return origArgs['1'] | |||
end | end | ||
function p. | function p.dnifont2nts(frame) | ||
-- If called via #invoke, use the args passed into the invoking template. | -- If called via #invoke, use the args passed into the invoking template. | ||
-- Otherwise, for testing purposes, assume args are being passed directly in. | -- Otherwise, for testing purposes, assume args are being passed directly in. | ||
Line 341: | Line 136: | ||
origArgs = frame:getParent().args | origArgs = frame:getParent().args | ||
else | else | ||
origArgs = frame | origArgs = frame | ||
end | end | ||
return dnifont2nts(origArgs[1]) | |||
end | end | ||
return p | return p |