1,749
edits
Lëtzelúcia (talk | contribs) m (almost done) |
Lëtzelúcia (talk | contribs) m (test) |
||
| Line 179: | Line 179: | ||
end | end | ||
}) | }) | ||
local cases = { | |||
["nominative"] = {short_form = "nom", link = "''[[nominative case|nominative]]''"}, | |||
["accusative"] = {short_form = "acc", link = "''[[accusative case|accusative]]''"}, | |||
["genitive"] = {short_form = "gen", link = "''[[genitive case|genitive]]''"}, | |||
["dative"] = {short_form = "dat", link = "''[[dative case|dative]]''"}, | |||
} | |||
local function make_headers(data, wikicode) | |||
table.insert(wikicode, '|- class="vsHide"\n') | |||
table.insert(wikicode, '! style="background:#' .. data.latincolour[3] .. '; font-style:italic;" | Number\n') | |||
table.insert(wikicode, '! style="background:#' .. data.latincolour[3] .. '; font-style:italic;" | Singular\n') | |||
table.insert(wikicode, '! style="background:#' .. data.latincolour[3] .. '; font-style:italic;" | Plural\n') | |||
end | |||
local function show_form(form, data, branch) | |||
local function convert_word(form, branch) | |||
if mw.ustring.find(form, "{{{") then | |||
return form | |||
else | |||
return m_vl_translit.convert_words(form, branch) | |||
end | |||
end | |||
if not form then | |||
return "—" | |||
end | |||
if title:inNamespace("") then | |||
return m_links.full_link({lang = lang, alt = convert_word(form, branch), term = form}) | |||
else | |||
return m_links.full_link({lang = lang, alt = convert_word(form, branch), term = "*" .. form}) | |||
end | |||
end | |||
local function make_case(data, wikicode, case, branch) | |||
local case_short = cases[case].short_form | |||
table.insert(wikicode, '|- class="vsHide"\n') | |||
table.insert(wikicode, '! style="background:#' .. data.latincolour[1] .. ';" | ' .. cases[case].link .. '\n') | |||
table.insert(wikicode, '| style="background:#' .. data.latincolour[2] .. ';" | ' .. show_form(data.forms[case_short .. '-sg'], data, branch) .. '\n') | |||
table.insert(wikicode, '| style="background:#' .. data.latincolour[2] .. ';" | ' .. show_form(data.forms[case_short .. '-pl'], data, branch) .. '\n') | |||
end | |||
local function make_table(data, branch) | |||
local wikicode = {'{| class="prettytable inflection-table vsSwitcher" data-toggle-category="inflection"\n'} | |||
table.insert(wikicode, '! colspan="5" class="vsToggleElement" style="text-align:left;min-width: 25em;background:#' .. | |||
data.latincolour[1] .. '" | ') | |||
table.insert(wikicode, branch_links[branch] .. ' declension of #head\n') | |||
make_headers(data, wikicode) | |||
make_case(data, wikicode, "nominative", branch) | |||
make_case(data, wikicode, "genitive", branch) | |||
make_case(data, wikicode, "dative", branch) | |||
make_case(data, wikicode, "accusative", branch) | |||
table.insert(wikicode, "|}") | |||
return table.concat(wikicode) | |||
end | |||