Module:cognates: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 12: Line 12:
nocap = false,
nocap = false,
}
}
--[[
function distance_sort(a, b)
local a = m_languages.get_by_code(a)
local b = m_languages.get_by_code(b)
local distance_a = m_languages.distance(nat, a)
local distance_b = m_languages.distance(nat, b)
if distance_a == distance_b then
return a.name < b.name
else
return distance_a < distance_b
end
end
table.sort(args, distance_sort(a, b))
]]--
for lang, entry in pairs(args) do
for lang, entry in pairs(args) do
Line 17: Line 34:
if m_languages.find_by_code(lang) and lang ~= nat then
if m_languages.find_by_code(lang) and lang ~= nat then
local term, data = m_inline.parse(entry)
local term, data = m_inline.parse(entry)
local cat = ""
data[1], data[2] = lang, term
data[1], data[2] = lang, term
local link = frame:expandTemplate{title = "m+", args = data}
local link = frame:expandTemplate{title = "m+", args = data}
if nat then
if nat then link = link .. "[[Category:" .. nat.name .. " terms with " .. lang.name .. " cognates]]" end
link = link .. "[[Category:" .. nat.name .. " terms with " .. lang.name .. " cognates]]"
end
table.insert(links, link)
table.insert(links, link)
elseif params[lang] ~= nil then --check for parameters
elseif params[lang] ~= nil then --check for parameters

Navigation menu