Модуль:Entity Lookup: различия между версиями

Нет описания правки
Нет описания правки
 
(не показаны 3 промежуточные версии этого же участника)
Строка 13: Строка 13:
local function buildName(entity, useSuffix)
local function buildName(entity, useSuffix)
local name = entity.name or ""
local name = entity.name or ""
local label = mw.text.trim(entity.label or ""):lower()
local label = mw.ustring.lower(entity.label or "")
local suffix = ""
local suffix = ""


if useSuffix then
if useSuffix then
local rawSuffix = entity.suffix
suffix = mw.ustring.lower(entity.suffix or "")
if rawSuffix and mw.text.trim(rawSuffix) ~= "" then
 
if suffix ~= "" then
local parts = {}
local parts = {}
for part in tostring(rawSuffix):gmatch("[^,;]+") do
for part in tostring(suffix):gmatch("[^,;]+") do
part = mw.text.trim(part)
part = mw.text.trim(part)
if part ~= "" then
if part ~= "" then
Строка 26: Строка 27:
end
end
end
end
if #parts > 0 then
suffix = table.concat(parts, ", ")
suffix = string.lower(table.concat(parts, ", "))
end
end
end
end
end
Строка 57: Строка 56:
local override = p.name_overrides[id]
local override = p.name_overrides[id]
if override then
if override then
return override
return lower(override)
end
end


Строка 65: Строка 64:
end
end


local useSuffix = frame.args and frame.args.suffix and mw.text.trim(frame.args.suffix) ~= ""
local useSuffix = frame.args and frame.args.suffix and frame.args.suffix ~= ""
return buildName(entity, useSuffix)
return buildName(entity, useSuffix)
end
end