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

Нет описания правки
Нет описания правки
 
(не показана 1 промежуточная версия этого же участника)
Строка 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 = mw.ustring.lower(entity.suffix or "")


if useSuffix then
if useSuffix and suffix ~= "" then
local rawSuffix = entity.suffix
local parts = {}
if rawSuffix and mw.text.trim(rawSuffix) ~= "" then
for part in tostring(suffix):gmatch("[^,;]+") do
local parts = {}
part = part
for part in tostring(rawSuffix):gmatch("[^,;]+") do
if part ~= "" then
part = mw.text.trim(part)
parts[#parts + 1] = part
if part ~= "" then
parts[#parts + 1] = part
end
end
if #parts > 0 then
suffix = table.concat(parts, ", "):lower()
end
end
end
end
suffix = table.concat(parts, ", ")
end
end


Строка 57: Строка 52:
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: Строка 60:
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