Module:letter headword: Difference between revisions
Created page with "local export = {} local force_cat = false local require_when_needed = require("Module:utilities/require when needed") local headword_module = "Module:headword" local headword_utilities_module = "Module:headword utilities" local JSON_module = "Module:JSON" local languages_module = "Module:languages" local parameters_module = "Module:parameters" local scripts_module = "Module:scripts" local table_module = "Module:table" local m_string_utilities = require("Module:string..." |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 47: | Line 47: | ||
end | end | ||
local function resolve_plus(termobjs, default, paramname) | local function resolve_plus(termobjs, default, paramname, lang) | ||
local saw_plus = false | local saw_plus = false | ||
for _, termobj in ipairs(termobjs) do | for _, termobj in ipairs(termobjs) do | ||
| Line 88: | Line 88: | ||
end | end | ||
local function parse_equivalent(value, default, paramname, no_prefix_colon) | local function parse_equivalent(value, default, paramname, no_prefix_colon, lang) | ||
if not value then | if not value then | ||
return nil | return nil | ||
| Line 116: | Line 116: | ||
termobjs = {{ term = value }} | termobjs = {{ term = value }} | ||
end | end | ||
termobjs = resolve_plus(termobjs, default, paramname) | termobjs = resolve_plus(termobjs, default, paramname, lang) | ||
for _, termobj in ipairs(termobjs) do | for _, termobj in ipairs(termobjs) do | ||
if not no_prefix_colon then | if not no_prefix_colon then | ||
| Line 272: | Line 272: | ||
} | } | ||
-- All letters can also be used as nouns ("There are two f's in that word"). | -- All letters can also be used as nouns ("There are two f's in that word"). | ||
local uppage = uupper(pagename) | local uppage = uupper(pagename) | ||
local lopage = ulower(pagename) | local lopage = ulower(pagename) | ||
| Line 317: | Line 313: | ||
insert(data.inflections, {label = "no case"}) | insert(data.inflections, {label = "no case"}) | ||
else | else | ||
local upper = parse_equivalent(args.upper or "+", ucfirstpage, "upper") | local upper = parse_equivalent(args.upper or "+", ucfirstpage, "upper", lang) | ||
local lower = parse_equivalent(args.lower or "+", lopage, "lower") | local lower = parse_equivalent(args.lower or "+", lopage, "lower", lang) | ||
local allcaps = parse_equivalent(args.allcaps or ulen(pagename) == 1 and args.upper or "+", uppage, "allcaps") | local allcaps = parse_equivalent(args.allcaps or ulen(pagename) == 1 and args.upper or "+", uppage, "allcaps", lang) | ||
local mixed = parse_equivalent(args.mixed, nil, "mixed") | local mixed = parse_equivalent(args.mixed, nil, "mixed", lang) | ||
local pagenameobj = {{term = ":" .. pagename, tr = "-"}} | local pagenameobj = {{term = ":" .. pagename, tr = "-"}} | ||
if typ == "upper" then | if typ == "upper" then | ||
| Line 377: | Line 373: | ||
local default_pls | local default_pls | ||
if iargs.pl_ending then | if iargs.pl_ending then | ||
default_pls = parse_equivalent(iargs.pl_ending, nil, "pl_ending", "no_prefix_colon") | default_pls = parse_equivalent(iargs.pl_ending, nil, "pl_ending", "no_prefix_colon", lang) | ||
for _, pl_ending in ipairs(default_pls) do | for _, pl_ending in ipairs(default_pls) do | ||
if pl_ending.term == "_" then | if pl_ending.term == "_" then | ||
| Line 386: | Line 382: | ||
end | end | ||
end | end | ||
local pls = parse_equivalent(args.pl or "+", default_pls, "pl") | local pls = parse_equivalent(args.pl or "+", default_pls, "pl", lang) | ||
if not pls[2] and pls[1].term == ":" .. pagename then | if not pls[2] and pls[1].term == ":" .. pagename then | ||
require(headword_utilities_module).insert_fixed_inflection { | require(headword_utilities_module).insert_fixed_inflection { | ||
| Line 399: | Line 395: | ||
if args.modern then | if args.modern then | ||
local termobjs = parse_equivalent(args.modern, nil, "modern") | local termobjs = parse_equivalent(args.modern, nil, "modern", lang) | ||
insert_inflection(termobjs, "modern equivalent") | insert_inflection(termobjs, "modern equivalent") | ||
end | end | ||
| Line 405: | Line 401: | ||
if others[1] then | if others[1] then | ||
for _, other in ipairs(others) do | for _, other in ipairs(others) do | ||
local termobjs = parse_equivalent(other.value, nil, other.obj:getCode()) | local termobjs = parse_equivalent(other.value, nil, other.obj:getCode(), lang) | ||
for _, termobj in ipairs(termobjs) do | for _, termobj in ipairs(termobjs) do | ||
if other.objtype == "language" then | if other.objtype == "language" then | ||