Module:Inflect senra: Difference between revisions
No edit summary |
No edit summary |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 9: | Line 9: | ||
local function template(language, word, tmpl) | local function template(language, word, tmpl) | ||
local lang = i18n[language] or i18n.en | local lang = i18n[language] or i18n.en | ||
return (tmpl:gsub("[%$-] | return (tmpl:gsub("[%$-]%w+", function(text) | ||
local suffix = text:match "%-(.*)" | local suffix = text:match "%-(.*)" | ||
local translation = text:match "%$(.*)" | local translation = text:match "%$(.*)" | ||
| Line 27: | Line 27: | ||
error("content word must be lemma (end with -u): "..word) | error("content word must be lemma (end with -u): "..word) | ||
end | end | ||
return | return template(language, word, [[<table class="wikitable"> | ||
<caption>$inflections </caption> | |||
<tr><th> <th>$regular <th>$infinitive <th>$imperative <th>$adverbial | |||
<tr><th> <td> <td>-u <td> <td> | |||
<tr><th>$intransitive <td>-i <td>-ui <td>-e <td>-iń | |||
<tr><th>$transitive <td>-a <td>-ua <td>-ea <td>-ań | |||
</table>]]) | |||
]] | |||
end | end | ||
| Line 49: | Line 44: | ||
intransitive = "intransitive", | intransitive = "intransitive", | ||
transitive = "transitive", | transitive = "transitive", | ||
} | |||
i18n.tok = { | |||
inflections = "ante nimi", | |||
regular = "pali", | |||
infinitive = "ijo", | |||
imperative = "wile", | |||
adverbial = "ante pali", | |||
intransitive = "pali tawa ijo ala", | |||
transitive = "pali tawa ijo", | |||
} | |||
i18n.eo = { | |||
inflections = "fleksioj", | |||
regular = "regula", | |||
infinitive = "infinitiva", | |||
imperative = "imperativa", | |||
adverbial = "adverba", | |||
intransitive = "netransitiva", | |||
transitive = "transitiva", | |||
} | } | ||
return p | return p | ||
Latest revision as of 23:26, 19 September 2025
Documentation for this module may be created at Module:Inflect senra/doc
local p = {}
local function change_suffix(word, suffix)
return (word:gsub("u$", suffix))
end
local i18n = {}
local function template(language, word, tmpl)
local lang = i18n[language] or i18n.en
return (tmpl:gsub("[%$-]%w+", function(text)
local suffix = text:match "%-(.*)"
local translation = text:match "%$(.*)"
if suffix then
return change_suffix(word, suffix)
elseif translation then
return lang[translation]
end
end))
end
function p.table(frame)
local language, word = frame.args[1], frame.args[2]
word = word:gsub("%s*$", "")
word = word:gsub("^%s*", "")
if not word:match"u$" then
error("content word must be lemma (end with -u): "..word)
end
return template(language, word, [[<table class="wikitable">
<caption>$inflections </caption>
<tr><th> <th>$regular <th>$infinitive <th>$imperative <th>$adverbial
<tr><th> <td> <td>-u <td> <td>
<tr><th>$intransitive <td>-i <td>-ui <td>-e <td>-iń
<tr><th>$transitive <td>-a <td>-ua <td>-ea <td>-ań
</table>]])
end
i18n.en = {
inflections = "inflections",
regular = "regular",
infinitive = "infinitive",
imperative = "imperative",
adverbial = "adverbial",
intransitive = "intransitive",
transitive = "transitive",
}
i18n.tok = {
inflections = "ante nimi",
regular = "pali",
infinitive = "ijo",
imperative = "wile",
adverbial = "ante pali",
intransitive = "pali tawa ijo ala",
transitive = "pali tawa ijo",
}
i18n.eo = {
inflections = "fleksioj",
regular = "regula",
infinitive = "infinitiva",
imperative = "imperativa",
adverbial = "adverba",
intransitive = "netransitiva",
transitive = "transitiva",
}
return p