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 = m_languages.get_by_code(args[1]) | local lang | ||
if mw.ustring.find(args[1], "%_") then | |||
lang = mw.ustring.match(args[1], "%_([^%_]+)$") | |||
lang = m_languages.get_by_code(lang) | |||
else | |||
lang = m_languages.get_by_code(args[1]) | |||
end | |||
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 49: | Line 55: | ||
for _, lang in ipairs(list) do | for _, lang in ipairs(list) do | ||
ancestors[lang] = {} | ancestors[lang] = {} | ||
for _, test in ipairs(list) do | if mw.ustring.find(lang, "%_") then | ||
local ancestor_temp | |||
for piece in mw.ustring.gmatch(lang, "([^%_]+)%_") do | |||
if ancestor_temp then | |||
ancestor_temp = ancestor_temp .. "_" .. piece | |||
else | |||
ancestor_temp = piece | |||
end | |||
table.insert(ancestors[lang], ancestor_temp) | |||
end | |||
else | |||
for _, test in ipairs(list) do | |||
if m_languages.get_by_code(lang).lineage[test] then | |||
table.insert(ancestors[lang], test) | |||
end | |||
end | end | ||
end | end | ||
Line 91: | Line 109: | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local out = "" | local out = "" | ||
local current_lang | local current_lang, code | ||
local terms = {} | local terms = {} | ||
local langs = {} | local langs = {} | ||
Line 99: | Line 117: | ||
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 | |||
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 | ||
if lang_change then | if lang_change then | ||
current_lang = | current_lang = lang_change | ||
term = mw.ustring.gsub(term, "^[^%:]+%:%s*", "") | term = mw.ustring.gsub(term, "^[^%:]+%:%s*", "") | ||
elseif lang_change_arged then | elseif lang_change_arged then | ||
current_lang = | current_lang = mw.ustring.match(lang_change_arged, "^[^%<]+") | ||
term = mw.ustring.gsub(term, "^.+%>%:%s*", "") | term = mw.ustring.gsub(term, "^.+%>%:%s*", "") | ||
end | end | ||
if | if mw.ustring.find(current_lang, "%_") then | ||
terms[ | from_lang, current_lang = mw.ustring.match(current_lang, "^(.*)%_([^%_]+)$") | ||
table.insert(langs, | if not mw.ustring.match(from_lang, "%_") then | ||
if lang_change_arged then | |||
lang_change_arged = lang_change_arged .. "<bor>" | |||
else | |||
lang_change_arged = "<bor>" | |||
end | |||
end | |||
end | |||
current_lang = m_languages.get_by_code(current_lang) | |||
code = current_lang.code | |||
if from_lang then code = from_lang .. "_" .. code end | |||
if terms[code] == nil then | |||
terms[code] = {} | |||
table.insert(langs, code) | |||
end | end | ||
end | end | ||
if lang_change_arged then | if lang_change_arged then | ||
for lang_arg in mw.ustring.gmatch(lang_change_arged, "%<([^%>]+)%>") do | for lang_arg in mw.ustring.gmatch(lang_change_arged, "%<([^%>]+)%>") do | ||
terms[ | terms[code][lang_arg] = true | ||
end | end | ||
end | end | ||
table.insert(terms[ | if from_lang then terms[code]["from"] = from_lang end | ||
table.insert(terms[code], term) | |||
end | end | ||