Module:descendants: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 9: Line 9:
local out = ""
local out = ""
local lang
local lang
if mw.ustring.find(args[1], "%_") then
if mw.ustring.find(args[1], "[%>%_]") then
lang = mw.ustring.match(args[1], "%_([^%_]+)$")
lang = mw.ustring.match(args[1], "[%>%_]([^%>%_]+)$")
lang = m_languages.get_by_code(lang)
lang = m_languages.get_by_code(lang)
else
else
Line 55: Line 55:
for _, lang in ipairs(list) do
for _, lang in ipairs(list) do
ancestors[lang] = {}
ancestors[lang] = {}
if mw.ustring.find(lang, "%_") then
if mw.ustring.find(lang, "[%>%_]") then
local ancestor_temp
local ancestor_temp = ""
for piece in mw.ustring.gmatch(lang, "([^%_]+)%_") do
for piece in mw.ustring.gmatch(lang, "([^%>%_]+[%>%_])") do
if ancestor_temp then
mw.log(piece)
ancestor_temp = ancestor_temp .. "_" .. piece
ancestor_temp = ancestor_temp .. piece
else
ancestor_add = mw.ustring.gsub(ancestor_temp, "[%>%_]$", "")
ancestor_temp = piece
table.insert(ancestors[lang], ancestor_add)
end
table.insert(ancestors[lang], ancestor_temp)
end
end
else
else
Line 127: Line 125:
term = mw.ustring.gsub(term, "^.+%>%:%s*", "")
term = mw.ustring.gsub(term, "^.+%>%:%s*", "")
end
end
if mw.ustring.find(current_lang, "%_") then
if mw.ustring.find(current_lang, "[%>%_][^%:]") then
from_lang, current_lang = mw.ustring.match(current_lang, "^(.*)%_([^%_]+)$")
from_lang, current_lang = mw.ustring.match(current_lang, "^(.*[%>%_])([^%>%_%:]+)$")
if not mw.ustring.match(from_lang, "%_") then
if mw.ustring.match(from_lang, "%>$") then
if lang_change_arged then
if lang_change_arged then
lang_change_arged = lang_change_arged .. "<bor>"
lang_change_arged = lang_change_arged .. "<bor>"
Line 139: Line 137:
current_lang = m_languages.get_by_code(current_lang)
current_lang = m_languages.get_by_code(current_lang)
code = current_lang.code
code = current_lang.code
if from_lang then code = from_lang .. "_" .. code end
if from_lang then code = from_lang .. code end
if terms[code] == nil then
if terms[code] == nil then
terms[code] = {}
terms[code] = {}
Line 209: Line 207:
Debug console test string:
Debug console test string:
=p.descendant(mw.getCurrentFrame():newChild{title="whatever",args={"rad"}})
=p.descendant(mw.getCurrentFrame():newChild{title="whatever",args={"rad"}})
=p.desctree(mw.getCurrentFrame():newChild{title="whatever",args={"rad<bor>:hello", "aeg:hello", "hi", "ryn:hello", "rad-o:hello", "rad-pro:hello", "hrd-pro:hi", "ryn-o:hihe", "lfv-pro:hihe", "lfv-o:hihe", "lfv:hihe"}})
=p.desctree(mw.getCurrentFrame():newChild{title="whatever",args={"ryn>rad-o:1", "aeg:2", "3", "ryn:4", "ryn>rad-o_rad:5", ">rad-pro:6", "hrd-pro:7", "ryn-o:8", "lfv-pro:9", "lfv-o:10", "lfv:11", "rad-pro:12"}})
]]--
]]--