Editing Module:Dict D'ni

From Guild of Archivists
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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 8: Line 8:
local origArgs
local origArgs
local root
local root
local function dnifont2ots(str)
    local output = mw.text.trim(str)
   
    output = mw.ustring.gsub(str,"%S",  {["S"] = "sh",
                                ["T"] = "th",
                                ["O"] = "oy",
                                ["c"] = "ch",
                                ["a"] = "ah",
                                ["E"] = "ee",
                                ["A"] = "ay",
                                ["u"] = "uh",
                                ["U"] = "oo",
                                ["x"] = "ts",
                                ["d"] = "dh",
                                ["D"] = "d",
                                ["k"] = "kh",
                                ["K"] = "k",
                                ["I"] = "ai",
                                ["å"] = "a",
                                })
    return output
end
local function dnifont2nts(str)
    local output = mw.text.trim(str)
   
    output = mw.ustring.gsub(str,"%S",  {["S"] = "š",
                                ["T"] = "þ",
                                ["O"] = "ó",
                                ["c"] = "ç",
                                ["E"] = "í",
                                ["A"] = "é",
                                ["U"] = "ú",
                                ["x"] = "c",
                                ["d"] = "ð",
                                ["D"] = "d",
                                ["k"] = "x",
                                ["K"] = "k",
                                ["I"] = "á",
                                ["å"] = "æ",
                                })
    return output
end


local function getArgNums(prefix)
local function getArgNums(prefix)
Line 74: Line 25:


         local output = ''
         local output = ''
         local sort = dnifont2ots(mw.ustring.sub(args['dnifont'],1,1))
         local sort = dnifont2ots(mw.ustring.sub(args['dnifont'],1,1))      
        local pagename = string.upper(mw.title.getCurrentTitle().text)
        if (mw.ustring.sub(pagename,1,1) == '-') then
          pagename = mw.ustring.sub(pagename,2)
        end


         output = output..'{{#vardefine:language|D\'ni}}{{#set: Lang=D\'ni }}'
         output = output..'==D\'ni==\n'
        output = output..'<h2>D\'ni</h2>\n'
         output = output..'{{huge|<d\'ni>'..args['dnifont']..'</d\'ni>}}\n'
         output = output..'{{huge|<dni>{{#vardefineecho:dnifont|'..args['dnifont']..'}}</dni>}}\n'
         output = output..'===Romanization==='
         output = output..'<h3>Romanization</h3>\n'
         output = output..'* [[Dnifont]]: '..args['dnifont']..'\n'
         output = output..'* [[Dnifont]]: [[Dnifont::'..args['dnifont']..']]\n'
         output = output..'* [[OTS]]: '..dnifont2ots(args['dnifont'])..'\n'
         output = output..'* [[OTS]]: [[OTS::'..dnifont2ots(args['dnifont'])..']]\n'
         output = output..'* [[NTS]]: '..dnifont2nts(args['dnifont'])..' '
         output = output..'* [[NTS]]: [[NTS::'..dnifont2nts(args['dnifont'])..']] '
         output = output..'[[Category:D\'ni words beginning with '..sort..']]\n'
         output = output..'[[Category:D\'ni words beginning with '..sort..']]'
         output = output..'[[Category:D\'ni words|'..sort..']]'
         output = output..'[[Category:D\'ni words|'..sort..']]'
        output = output..'{{DEFAULTSORT:'..pagename..'}}'


     return output
     return output
Line 176: Line 120:
end
end


function p.dnifont2ots(str)
function p.smw_format_gloss(frame)
 
    -- If called via #invoke, use the args passed into the invoking template.
     local output = mw.text.trim(str)
    -- Otherwise, for testing purposes, assume args are being passed directly in.
     if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
      
      
     -- Parse the data parameters
     output = output:gsub("%S+", {["S"] = "sh",
    preprocessSingleArg(1)
                                ["T"] = "th",
    preprocessSingleArg(2)
                                ["O"] = "oy",
                                ["c"] = "ch",
                                ["a"] = "ah",
                                ["E"] = "ee",
                                ["A"] = "ay",
                                ["u"] = "uh",
                                ["U"] = "oo",
                                ["x"] = "ts",
                                ["d"] = "dh",
                                ["D"] = "d",
                                ["k"] = "kh",
                                ["K"] = "k",
                                ["I"] = "ai",
                                ["å"] = "a",
                                })


    wordtype = string.lower(string.gsub(args[1],'.*#',''))
    return output
    if (string.find(args[2],"^",1,true) == nil) then
      glosses = args[2]
    elseif (args[2] == nil) then
      glosses = ""
    else
      glosses = '<ol class="hlist-ordered"><li>'..string.gsub(args[2],"%^","</li><li>").."</li></ol>"
    end
    glosses = string.gsub(string.gsub(glosses,'%[%[%s*[Cc]ategory%s*:.-%]%]', ''),"|","{{!}}")
 
    output = "''"..wordtype.."''.&nbsp;"..glosses
 
    return output   --frame:preprocess(_dni_entry())
end
end
function p.dnifont2nts(str)


function p.smw_format_dict_line(frame)
     local output = mw.text.trim(str)
    -- If called via #invoke, use the args passed into the invoking template.
    -- Otherwise, for testing purposes, assume args are being passed directly in.
     if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
      
      
     -- Parse the data parameters
     output = output:gsub("%S+", {["S"] = "š",
    preprocessSingleArg(1) --word
                                ["T"] = "þ",
    preprocessSingleArg(2) --dnifont
                                ["O"] = "ó",
    preprocessSingleArg(3) --glosses
                                ["c"] = "ç",
                                ["E"] = "i",
                                ["A"] = "é",
                                ["U"] = "ú",
                                ["x"] = "c",
                                ["d"] = "ð",
                                ["D"] = "d",
                                ["k"] = "x",
                                ["K"] = "k",
                                ["I"] = "á",
                                ["å"] = "æ",
                                })


 
    return output
    output = "'''''[[Dictionary:"..args[1].."|"..mw.ustring.lower(args[1]).."]]'''''&nbsp;-&nbsp;<span class='dni'>"..args[2].."</span>&nbsp;- "..args[3]
 
    return output --frame:preprocess(output)
end
 
function p.dnifont2ots(frame)
    -- If called via #invoke, use the args passed into the invoking template.
    -- Otherwise, for testing purposes, assume args are being passed directly in.
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
 
    preprocessSingleArg(1)
 
    return dnifont2ots(args[1])
end
 
function p.dnifont2nts(frame)
    -- If called via #invoke, use the args passed into the invoking template.
    -- Otherwise, for testing purposes, assume args are being passed directly in.
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
 
    preprocessSingleArg(1)
 
    return dnifont2nts(args[1])
end
end


return p
return p
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see GoArch:Copyrights for details). Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: