Modul:hi-decl/noun
Megjelenés
A modult a Modul:hi-decl/noun/doc lapon tudod dokumentálni
local export = {}
local m_translit = require("Module:hi-translit")
local util = require("Module:hi")
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local match = mw.ustring.match
local len = mw.ustring.len
local hi_format = util.hi_format
local wordify = util.wordify
local function decline(word, gender)
if gender == "m" then
if match(word, "[क-ह]$") then
s_obl, s_voc, p_nom, p_obl, p_voc = word, word, word, word .. "ों", word .. "ो"
end
end
if gender == "f" then
if match(word, "[क-ह]$") then
s_obl, s_voc, p_nom, p_obl, p_voc = word, word, word .. "ें", word .. "ों", word .. "ो"
end
end
return s_obl, s_voc, p_nom, p_obl, p_voc
end
local function make_row(case, s, p)
local data = {}
table.insert(data, [=[
|- class="vsHide"
| style="background:#eff7ff" | '']=] .. case .. "''")
table.insert(data, '|' .. wordify(s))
table.insert(data, '|' .. wordify(p))
return table.concat(data, "\n")
end
function export.show(frame)
local args = frame:getParent().args
local word = args[2] or mw.title.getCurrentTitle().text
local gender = args[1] or args["g"]
if word == "hi-noun-auto" then
word = "शब्द" -- default
gender = "m"
end
if gender ~= "m" and gender ~= "f" then
error("Not a valid gender; must be 'm' or 'f'.")
end
local s_obl, s_voc, p_nom, p_obl, p_voc = decline(word, gender)
local s_nom = word
local data = {'{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background:#F9F9F9; text-align:center; border: 1px solid #CCC; width: 35em"'}
table.insert(data, '|- style="background: #d9ebff;"')
table.insert(data, '! class="vsToggleElement" style="text-align: left;" colspan="3" | Declension of ' .. hi_format(word))
table.insert(data, [=[
|- class="vsHide"
! style="background:#eff7ff" |
! style="background:#eff7ff" | Singular
! style="background:#eff7ff" | Plural]=])
table.insert(data, make_row('Direct', s_nom, p_nom))
table.insert(data, make_row('Oblique', s_obl, p_obl))
table.insert(data, make_row('Vocative', s_voc, p_voc))
table.insert(data, "|}")
return table.concat(data, "\n")
end
return export