Editing Module:Dict D'ni
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 9: | Line 9: | ||
local root | local root | ||
local function getArgNums(prefix) | |||
-- Returns a table containing the numbers of the arguments that exist | |||
-- for the specified prefix. For example, if the prefix was 'data', and | |||
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}. | |||
local nums = {} | |||
for k, v in pairs(args) do | |||
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$') | |||
if num then table.insert(nums, tonumber(num)) end | |||
end | |||
table.sort(nums) | |||
return nums | |||
end | |||
local function | local function _dni_word_entry() | ||
local output | |||
local sort = string.sub(args['dnifont'],1,1) | |||
sort = sort:gsub("%S+", {["S"] = "sh", | |||
["T"] = "th", | ["T"] = "th", | ||
["O"] = "oy", | ["O"] = "oy", | ||
Line 29: | Line 41: | ||
["K"] = "k", | ["K"] = "k", | ||
["I"] = "ai", | ["I"] = "ai", | ||
["k"] = "kh", | |||
["å"] = "a", | ["å"] = "a", | ||
}) | }) | ||
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' | |||
output = output..'[[Category:D\'ni Words beginning with '..sort..']]\n' | |||
output = output..'[[Category:D\'ni Words|'..sort..']]\n' | |||
output = output..'{{ | |||
output = output..' | |||
output = output..'* [[Dnifont]] | |||
output = output..'* [[OTS]] | |||
output = output..'* [[NTS]] | |||
output = output..'[[Category:D\'ni | |||
output = output..'[[Category:D\'ni | |||
return output | return output | ||
Line 161: | Line 124: | ||
end | end | ||
function p. | 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 134: | ||
-- Parse the data parameters | -- Parse the data parameters | ||
preprocessSingleArg('type') | |||
preprocessSingleArg('dnifont') | preprocessSingleArg('dnifont') | ||
preprocessSingleArg('ipa') | |||
return frame:preprocess( | preprocessSingleArg('ots') | ||
preprocessSingleArg('nts') | |||
return frame:preprocess(_dni_word_entry()) | |||
end | end | ||
return p | return p |