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 71: |
Line 22: |
| end | | end |
|
| |
|
| local function _dni_entry()
| |
|
| |
|
| local output = ''
| | local function renderTrackingCategories() |
| local sort = dnifont2ots(mw.ustring.sub(args['dnifont'],1,1)) | | if args.decat ~= 'yes' then |
| local pagename = string.upper(mw.title.getCurrentTitle().text)
| | if #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then |
| if (mw.ustring.sub(pagename,1,1) == '-') then
| | root:wikitext('[[Category:Articles which use infobox templates with no data rows]]') |
| pagename = mw.ustring.sub(pagename,2)
| |
| end | | end |
| | if args.child == 'yes' and args.title then |
| | root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]') |
| | end |
| | end |
| | end |
|
| |
|
| output = output..'{{#vardefine:language|D\'ni}}{{#set: Lang=D\'ni }}'
| | local function _dni_word_entry() |
| output = output..'<h2>D\'ni</h2>\n'
| |
| output = output..'{{huge|<dni>{{#vardefineecho:dnifont|'..args['dnifont']..'}}</dni>}}\n'
| |
| output = output..'<h3>Romanization</h3>\n'
| |
| output = output..'* [[Dnifont]]: [[Dnifont::'..args['dnifont']..']]\n'
| |
| output = output..'* [[OTS]]: [[OTS::'..dnifont2ots(args['dnifont'])..']]\n'
| |
| output = output..'* [[NTS]]: [[NTS::'..dnifont2nts(args['dnifont'])..']] '
| |
| output = output..'[[Category:D\'ni words beginning with '..sort..']]'
| |
| output = output..'[[Category:D\'ni words|'..sort..']]'
| |
| | |
| output = output..'{{DEFAULTSORT:'..pagename..'}}'
| |
|
| |
|
| | local output |
| | |
| | output = '===D\'ni===\n' |
| | output = output..'{{huge|<d\'ni>'..args['dnifont']..'</d\'ni>}}\n' |
| | output = output..'* [[wikipedia:International Phonetic Alphabet|IPA]]: ['..args['ipa']..']\n' |
| | output = output..'* [[Dnifont]]: '..args['dnifont']..'\n' |
| | output = output..'* [[OTS]]: '..args['ots']..'\n' |
| | output = output..'* [[NTS]]: '..args['nts']..'\n' |
| | |
| return output | | return output |
| end | | end |
Line 161: |
Line 114: |
| end | | end |
| | | |
| function p.dict_entry(frame) | | function p.dict_word_entry(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 171: |
Line 124: |
| | | |
| -- Parse the data parameters | | -- Parse the data parameters |
| | preprocessSingleArg('type') |
| preprocessSingleArg('dnifont') | | preprocessSingleArg('dnifont') |
| | | preprocessSingleArg('ipa') |
| return frame:preprocess(_dni_entry()) | | preprocessSingleArg('ots') |
| | preprocessSingleArg('nts') |
| | |
| | return frame:preprocess(_dni_word_entry()) |
| end | | end |
|
| |
| | | |
| function p.smw_format_gloss(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
| |
|
| |
| -- Parse the data parameters
| |
| preprocessSingleArg(1)
| |
| preprocessSingleArg(2)
| |
|
| |
| wordtype = string.lower(string.gsub(args[1],'.*#',''))
| |
| 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.."''. "..glosses
| |
|
| |
| return output --frame:preprocess(_dni_entry())
| |
| end
| |
|
| |
| function p.smw_format_dict_line(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
| |
|
| |
| -- Parse the data parameters
| |
| preprocessSingleArg(1) --word
| |
| preprocessSingleArg(2) --dnifont
| |
| preprocessSingleArg(3) --glosses
| |
|
| |
|
| |
| output = "'''''[[Dictionary:"..args[1].."|"..mw.ustring.lower(args[1]).."]]''''' - <span class='dni'>"..args[2].."</span> - "..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
| |
|
| |
| return p | | return p |