10,731
edits
TheNightAvl (talk | contribs) No edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
Line 8: | Line 8: | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local out = "" | local out = "" | ||
local lang | local lang = args[1] | ||
if mw.ustring.find( | if mw.ustring.find(lang, "[%>%_]") then | ||
lang = mw.ustring.match( | lang = mw.ustring.match(lang, "[%>%_]([^%>%_]+)$") | ||
end | |||
if mw.ustring.find(lang, "[0-9]+$") then | |||
lang = | lang = mw.ustring.gsub(lang, "[0-9]+$", "") | ||
end | end | ||
lang = m_languages.get_by_code(lang) | |||
local borrowed = args["borrowed"] or args["bor"] or args["b"] | local borrowed = args["borrowed"] or args["bor"] or args["b"] | ||
local see_desc = args["see"] | local see_desc = args["see"] | ||
Line 58: | Line 59: | ||
local ancestor_temp = "" | local ancestor_temp = "" | ||
for piece in mw.ustring.gmatch(lang, "([^%>%_]+[%>%_])") do | for piece in mw.ustring.gmatch(lang, "([^%>%_]+[%>%_])") do | ||
ancestor_temp = ancestor_temp .. piece | ancestor_temp = ancestor_temp .. piece | ||
ancestor_add = mw.ustring.gsub(ancestor_temp, "[%>%_]$", "") | ancestor_add = mw.ustring.gsub(ancestor_temp, "[%>%_]$", "") | ||
table.insert(ancestors[lang], ancestor_add) | table.insert(ancestors[lang], ancestor_add) | ||
end | |||
elseif mw.ustring.find(lang, "[0-9]+$") then | |||
local lang_temp, index = mw.ustring.match(lang, "^([^0-9]+)([0-9]+)$") | |||
for _, test in ipairs(list) do | |||
if mw.ustring.find(test, index .. "$") then | |||
local test_temp = mw.ustring.gsub(test, index .. "$", "") | |||
if m_languages.get_by_code(lang_temp).lineage[test_temp] then | |||
table.insert(ancestors[lang], test) | |||
end | |||
elseif m_languages.get_by_code(lang_temp).lineage[test] then | |||
local nope = false | |||
for _, contain_test in ipairs(list) do | |||
if contain_test == test .. index then nope = true end | |||
end | |||
if not nope then table.insert(ancestors[lang], test) end | |||
end | |||
end | end | ||
else | else | ||
Line 115: | Line 131: | ||
local lang_change = mw.ustring.match(term, "^([^%:%<]+)%:") | local lang_change = mw.ustring.match(term, "^([^%:%<]+)%:") | ||
local lang_change_arged = mw.ustring.match(term, "^(.+%>)%:") | local lang_change_arged = mw.ustring.match(term, "^(.+%>)%:") | ||
local from_lang | local from_lang, index | ||
if i == 1 and not (lang_change or lang_change_arged) then error("Language code needs to be specified in the first parameter as xyz(<bor>):term₁") end | if i == 1 and not (lang_change or lang_change_arged) then error("Language code needs to be specified in the first parameter as xyz(<bor>):term₁") end | ||
if lang_change or lang_change_arged then | if lang_change or lang_change_arged then | ||
Line 134: | Line 150: | ||
end | end | ||
end | end | ||
end | |||
if mw.ustring.find(current_lang, "[0-9]+$") then | |||
current_lang, index = mw.ustring.match(current_lang, "^(.*)([0-9]+)$") | |||
end | end | ||
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 index then code = code .. index end | |||
if terms[code] == nil then | if terms[code] == nil then | ||
terms[code] = {} | terms[code] = {} |