Module:category tree/topic/utilities: Difference between revisions

m 1 revision imported
m top: clean up
 
Line 23: Line 23:
--
--
-- The main use of `no_singularize` is with plural-form terms that also exist in the singular but have special meanings
-- The main use of `no_singularize` is with plural-form terms that also exist in the singular but have special meanings
-- in the plural that are different from the corresponding singular (e.g. [[acoustics]] is not the plural of
-- in the plural that are different from the corresponding singular (e.g. [[wikt:acoustics|acoustics]] is not the plural of
-- [[acoustic]], but will be incorrectly linked as [[acoustic]]s unless `no_singularize` is given).
-- [[wikt:acoustic|acoustic]], but will be incorrectly linked as [[wikt:acoustic|acoustic]]s unless `no_singularize` is given).
function export.link_label(label, no_singularize, wikify)
function export.link_label(label, no_singularize, wikify)
local function term_exists(term)
local function term_exists(term)
Line 50: Line 50:
elseif term_exists(label) then
elseif term_exists(label) then
-- Then check if the original label as a whole exists, and return if so.
-- Then check if the original label as a whole exists, and return if so.
return "[[" .. label .. "]]"
return "[[wikt:" .. label .. "|" .. label .. "]]"
else
else
-- Otherwise, if the label is multiword, split into words and try the link each one, singularizing the last
-- Otherwise, if the label is multiword, split into words and try the link each one, singularizing the last
Line 69: Line 69:
else
else
if term_exists(word) then
if term_exists(word) then
split_label[i] = "[[" .. word .. "]]"
split_label[i] = "[[wikt:" .. word .. "|" .. word .. "]]"
else
else
split_label = nil
split_label = nil
Line 86: Line 86:
for i, word in ipairs(split_label) do
for i, word in ipairs(split_label) do
if term_exists(word) then
if term_exists(word) then
split_label[i] = "[[" .. word .. "]]"
split_label[i] = "[[wikt:" .. word .. "|" .. word .. "]]"
else
else
split_label = nil
split_label = nil