Module:rad-stem/templates: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) mNo edit summary |
TheNightAvl (talk | contribs) mNo edit summary |
||
Line 47: | Line 47: | ||
end | end | ||
function export. | function export.show(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local stems = get_stems(args) | local stems = get_stems(args) | ||
Line 59: | Line 59: | ||
local format_table = {} | local format_table = {} | ||
local decl_type = { | |||
["C"] = "heavy", | |||
["CH"] = "heavy spirant", | |||
["VH"] = "light spirant", | |||
["V"] = "light", | |||
["G"] = "semi-light" | |||
} | |||
local type_name = decl_type[stems['type']] | |||
local table_type = args['type'] or "sgpl" | |||
local function add(code) | local function add(code) | ||
Line 65: | Line 77: | ||
local function th(data, rowspan, colspan) | local function th(data, rowspan, colspan) | ||
local to_add = "<th" | |||
if rowspan and rowspan~=1 then | if rowspan and rowspan~=1 then to_add = to_add .. " rowspan=" .. rowspan end | ||
if colspan and colspan~=1 then | if colspan and colspan~=1 then to_add = to_add .. " colspan=" .. colspan end | ||
to_add = to_add .. ">" .. data .. "</th>" | |||
add(to_add) | |||
end | end | ||
local function td(data, rowspan, colspan) | local function td(data, rowspan, colspan) | ||
local to_add = "<td" | |||
if rowspan and rowspan~=1 then | if rowspan and rowspan~=1 then to_add = to_add .. " rowspan=" .. rowspan end | ||
if colspan and colspan~=1 then | if colspan and colspan~=1 then to_add = to_add .. " colspan=" .. colspan end | ||
to_add = to_add .. ">" .. data .. "</td>" | |||
add(to_add) | |||
end | end | ||
add("<table class=\"mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">") | add("<table class=\"mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">") | ||
if table_type == "sgpl" then | |||
th("Declension of <i>" .. stems.nom .. "</i> (" .. type_name .. ")  ", 1, 4) | th("Declension of <i>" .. stems.nom .. "</i> (" .. type_name .. ")  ", 1, 4) | ||
end | |||
add("</table>") | add("</table>") | ||
add("<includeonly>[[Category:Radestrian " .. type_name .. " stems]]</includeonly>") | add("<includeonly>[[Category:Radestrian " .. type_name .. " stems]]</includeonly>") | ||
return table.concat(format_table) | return table.concat(format_table, string.char(10)) | ||
end | end | ||
Line 103: | Line 107: | ||
--[[ | --[[ | ||
Debug console test string: | Debug console test string: | ||
=p. | =p.show(mw.getCurrentFrame():newChild{title="whatever",args={"hv", "o~u^u", "þ"}}) | ||
]]-- | ]]-- |
Revision as of 11:25, 1 December 2023
local export = {}
local getArgs = require('Module:Arguments').getArgs
local m_stem = require("Module:rad-stem")
local m_parameters = require("Module:parameters")
function get_stems(args)
local shifted = {"noun", "_"}
local i = 1
while args[i] do
shifted[i+2] = args[i]
i = i + 1
end
return m_stem.getNounStem(shifted)
end
function break_adj(adj)
local C = "bcdðfghħjĵkķlmnņpqrsștvwxzþ°"
local temp = adj
temp = mw.ustring.gsub(temp, "([" .. C .. "])([" .. C .. "])íș$", "%1%2ieș")
temp = mw.ustring.gsub(temp, "(°)", "")
temp = mw.ustring.gsub(temp, "(íș)$", "jeș")
temp = mw.ustring.gsub(temp, "(úș)$", "uoș")
temp = mw.ustring.gsub(temp, "(ýș)$", "yeș")
temp = mw.ustring.gsub(temp, "(oș)$", "uș")
return temp
end
function rad_link(word)
return require("Module:links").full_link{
term = word,
language = m_languages.get_by_code("rad")
}
end
function rad_IPA(word)
local IPA = require("Module:rad-IPA").generate{
word,
"format",
"nolarge"
}
return "<span style=\"color:dimgrey\">" .. IPA .. "</span>"
end
function export.show(frame)
local args = getArgs(frame)
local stems = get_stems(args)
local adj = args['adj']
local adj_broken = ""
local adj_broken_e = ""
if adj then
adj_broken = args['adjbreak'] or break_adj(adj)
adj_broken_e = mw.ustring.gsub(adj_broken, "(uș)$", "ûș")
end
local format_table = {}
local decl_type = {
["C"] = "heavy",
["CH"] = "heavy spirant",
["VH"] = "light spirant",
["V"] = "light",
["G"] = "semi-light"
}
local type_name = decl_type[stems['type']]
local table_type = args['type'] or "sgpl"
local function add(code)
table.insert(format_table, code)
end
local function th(data, rowspan, colspan)
local to_add = "<th"
if rowspan and rowspan~=1 then to_add = to_add .. " rowspan=" .. rowspan end
if colspan and colspan~=1 then to_add = to_add .. " colspan=" .. colspan end
to_add = to_add .. ">" .. data .. "</th>"
add(to_add)
end
local function td(data, rowspan, colspan)
local to_add = "<td"
if rowspan and rowspan~=1 then to_add = to_add .. " rowspan=" .. rowspan end
if colspan and colspan~=1 then to_add = to_add .. " colspan=" .. colspan end
to_add = to_add .. ">" .. data .. "</td>"
add(to_add)
end
add("<table class=\"mw-collapsible mw-collapsed wikitable inflection table\" style=\"text-align: center\">")
if table_type == "sgpl" then
th("Declension of <i>" .. stems.nom .. "</i> (" .. type_name .. ")  ", 1, 4)
end
add("</table>")
add("<includeonly>[[Category:Radestrian " .. type_name .. " stems]]</includeonly>")
return table.concat(format_table, string.char(10))
end
return export
--[[
Debug console test string:
=p.show(mw.getCurrentFrame():newChild{title="whatever",args={"hv", "o~u^u", "þ"}})
]]--