Module:headword/templates and Module:headword/templates/sandbox: Difference between pages
(Difference between pages)
Content deleted Content added
m remove no-longer-need 'etym_lang = true' setting (manually assisted) |
Created page with "local export = {} -- Part of speech types that should not be pluralized. local invariable = mw.loadData("Module:headword/data").invariable function export.head_t(frame) local plain_param = {} local list_with_holes = {list = true, allow_holes = true} local boolean_list_with_holes = {list = true, allow_holes = true, type = "boolean"} local params = { [1] = {required = true, default = "und"}, ["sc"] = plain_param, ["sort"] = plain_param, [2] = {required = t..." |
||
Line 1: | Line 1: | ||
⚫ | |||
local export = {} |
local export = {} |
||
-- Part of speech types that should not be pluralized. |
|||
⚫ | |||
⚫ | |||
local boolean = {type = "boolean"} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
return process_params(frame:getParent().args, { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local plain_param = {} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
[2] = {required = true, default = "nouns"}, |
[2] = {required = true, default = "nouns"}, |
||
["sccat"] = boolean, |
["sccat"] = boolean, |
||
["noposcat"] = boolean, |
["noposcat"] = boolean, |
||
["nomultiwordcat"] = boolean, |
["nomultiwordcat"] = boolean, |
||
["nogendercat"] = boolean, |
["nogendercat"] = boolean, |
||
["nopalindromecat"] = boolean, |
["nopalindromecat"] = boolean, |
||
[" |
[""] = boolean, |
||
[" |
[""] = , |
||
[" |
[""] = , |
||
[" |
[""] = , |
||
["cat4"] = plain, |
|||
["head"] = |
["head"] = , |
||
["id"] = |
["id"] = , |
||
["tr"] = |
["tr"] = , |
||
["ts"] = |
["ts"] = , |
||
["gloss"] = plain, |
|||
["g"] = {list = true}, |
["g"] = {list = true}, |
||
["g |
["g"] = , |
||
[3] = |
[3] = , |
||
["f |
["f-form"] = , |
||
["f |
["f-translit"] = , |
||
["f |
["f-lemma"] = , |
||
["f |
["f-lemma-translit"] = , |
||
["f |
["f-gender"] = , |
||
["f |
["f-nostore"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
["f |
["f"] = , |
||
} |
} |
||
⚫ | |||
⚫ | |||
function export.head_t(frame) |
|||
local function track(page) |
|||
require("Module:debug/track")("headword/templates/" .. page) |
|||
return true |
|||
⚫ | |||
local args = get_args(frame) |
|||
-- Get language and script information |
-- Get language and script information |
||
local data = {} |
local data = {} |
||
data.lang = require("Module:languages").getByCode(args[1]) or require("Module:languages").err(args[1], 1) |
|||
⚫ | |||
data.sc = args["sc"] |
|||
data.sccat = args["sccat"] |
|||
data.sort_key = args["sort"] |
data.sort_key = args["sort"] |
||
data.heads = args["head"] |
data.heads = args["head"] |
||
Line 73: | Line 62: | ||
data.translits = args["tr"] |
data.translits = args["tr"] |
||
data.transcriptions = args["ts"] |
data.transcriptions = args["ts"] |
||
data.gloss = args["gloss"] |
|||
data.genders = args["g"] |
data.genders = args["g"] |
||
-- This shouldn't really happen. |
|||
for i = 1,args["head"].maxindex do |
|||
if not args["head"][i] then |
|||
track("head-with-holes") |
|||
⚫ | |||
end |
|||
for k, v in pairs(args["gqual"]) do |
for k, v in pairs(args["gqual"]) do |
||
if k ~= "maxindex" then |
if k ~= "maxindex" then |
||
Line 91: | Line 73: | ||
end |
end |
||
end |
end |
||
-- Script |
|||
data.sc = args["sc"] and require("Module:scripts").getByCode(args["sc"], "sc") or nil |
|||
⚫ | |||
-- Part-of-speech category |
-- Part-of-speech category |
||
data.pos_category = args[2] |
data.pos_category = args[2] |
||
data.noposcat = args["noposcat"] |
data.noposcat = args["noposcat"] |
||
⚫ | |||
⚫ | |||
-- Check for headword aliases and then pluralize if the POS term does not have an invariable plural. |
|||
⚫ | |||
⚫ | |||
-- Make the plural form of the part of speech |
-- Make the plural form of the part of speech |
||
data.pos_category:("x$", |
|||
⚫ | |||
else |
|||
data.pos_category = data.pos_category .. "s" |
|||
⚫ | |||
end |
end |
||
-- Additional categories |
-- Additional categories |
||
data.categories = {} |
data.categories = {} |
||
data.whole_page_categories = {} |
|||
data.nomultiwordcat = args["nomultiwordcat"] |
data.nomultiwordcat = args["nomultiwordcat"] |
||
data.nogendercat = args["nogendercat"] |
data.nogendercat = args["nogendercat"] |
||
data.nopalindromecat = args["nopalindromecat"] |
data.nopalindromecat = args["nopalindromecat"] |
||
if args["cat2"] then |
if args["cat2"] then |
||
table.insert(data.categories, data.lang: |
table.insert(data.categories, data.lang:() .. " " .. args["cat2"]) |
||
end |
end |
||
if args["cat3"] then |
if args["cat3"] then |
||
table.insert(data.categories, data.lang: |
table.insert(data.categories, data.lang:() .. " " .. args["cat3"]) |
||
end |
end |
||
if args["cat4"] then |
if args["cat4"] then |
||
table.insert(data.categories, data.lang: |
table.insert(data.categories, data.lang:() .. " " .. args["cat4"]) |
||
end |
end |
||
-- Headword linking |
|||
data.nolinkhead = args["nolinkhead"] |
|||
-- Inflected forms |
-- Inflected forms |
||
data.inflections = {enable_auto_translit = args["autotrinfl"]} |
data.inflections = {enable_auto_translit = args["autotrinfl"]} |
||
for i = 1, math.ceil(args[3].maxindex / 2) do |
for i = 1, math.ceil(args[3].maxindex / 2) do |
||
local infl_part = { |
local infl_part = { |
||
Line 151: | Line 133: | ||
id = args["fid"][i], |
id = args["fid"][i], |
||
lang = args["flang"][i], |
lang = args["flang"][i], |
||
= args["fnolink"][i], |
|||
= {args["fqual"][i]}, |
|||
sc = args["fsc"][i], |
sc = args["fsc"][i], |
||
translit = args["ftr"][i], |
translit = args["ftr"][i], |
||
transcription = args["fts"][i], |
transcription = args["fts"][i], |
||
} |
} |
||
if form.lang then |
|||
form.lang = require("Module:languages").getByCode(form.lang) or require("Module:languages").err(form.lang, "f" .. i .. "lang") |
|||
⚫ | |||
if form.sc then |
|||
form.sc = require("Module:scripts").getByCode(form.sc) or error("The script code \"" .. form.sc .. "\" is not valid.") |
|||
⚫ | |||
-- If no term or alt is given, then the label is shown alone. |
-- If no term or alt is given, then the label is shown alone. |