Module:cognates: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 13: Line 13:
}
}
--[[
local langs = {}
function distance_sort(a, b)
if type(a) ~= "string" or m_languages.find_by_code(a) == nil then
return a < b
end
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
if type(lang) == "string" then
if type(lang) == "string" then
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)
table.insert(langs, lang)
data[1], data[2] = lang, term
--local term, data = m_inline.parse(entry)
local link = frame:expandTemplate{title = "m+", args = data}
--data[1], data[2] = lang, term
if nat then link = link .. "[[Category:" .. nat.name .. " terms with " .. lang.name .. " cognates]]" end
--local link = frame:expandTemplate{title = "m+", args = data}
table.insert(links, link)
--if nat then link = link .. "[[Category:" .. nat.name .. " terms with " .. lang.name .. " cognates]]" end
--table.insert(links, link)
elseif params[lang] ~= nil then --check for parameters
elseif params[lang] ~= nil then --check for parameters
params[lang] = true
params[lang] = true
Line 47: Line 30:
end
end
end
end
end
table.sort(langs, function(a, b)
a = m_languages.get_by_code(a)
b = m_languages.get_by_code(b)
a_test = m_languages.stage_at_split(nat, a)
b_test = m_languages.stage_at_split(nat, b)
if a_test == b_test then
return a.name < b.name
else
return a_test > b_test
end
end
)
for _, lang in ipairs(langs) do
end
end

Navigation menu