Module:head: Difference between revisions

Replaced string library with mw.ustring library, as epenthetic "e" in pluralisation was not working.
No edit summary
(Replaced string library with mw.ustring library, as epenthetic "e" in pluralisation was not working.)
Line 6: Line 6:


local function is_non_lemma(pos)
local function is_non_lemma(pos)
return string.find(pos, "%sform") and true or false
return mw.ustring.find(pos, "%sform") and true or false
end
end


local function pluralize(word)
local function pluralize(word)
local ending = string.sub(word, -1)
local ending = mw.ustring.sub(word, -1)
if ending == "h" and string.sub(word, -2, -1) == "s" then ending = "sh" end
if ending == "h" and mw.ustring.sub(word, -2, -1) == "s" then ending = "sh" end
if ending == "s" or ending == "z" or ending == "x" or ending == "sh" then
if ending == "s" or ending == "z" or ending == "x" or ending == "sh" then
return word .. "es"
return word .. "es"
Line 29: Line 29:
if data.head then
if data.head then
head = data.head
head = data.head
elseif string.find(head, " ") then
elseif mw.ustring.find(head, " ") then
local pieces = {}
local pieces = {}
for piece in string.gmatch(head, "%S+") do
for piece in mw.ustring.gmatch(head, "%S+") do
table.insert(pieces, "[[" .. piece .. "]]")
table.insert(pieces, "[[" .. piece .. "]]")
end
end
head = table.concat(pieces, " ")
head = table.concat(pieces, " ")
end
end
if string.find(head, " ") then
if mw.ustring.find(head, " ") then
cats = cats .. "[[Category:" .. data.language.name .. " multiword terms]]"
cats = cats .. "[[Category:" .. data.language.name .. " multiword terms]]"
end
end