10,731
edits
TheNightAvl (talk | contribs) m (Optimisation) |
TheNightAvl (talk | contribs) m (Optimisation) |
||
Line 129: | Line 129: | ||
for i, term in ipairs(args) do --ryn:term1|term2|term3|rad:term1|term2 ... | for i, term in ipairs(args) do --ryn:term1|term2|term3|rad:term1|term2 ... | ||
local lang_change = mw.ustring.match(term, "^([^%:%<]+)%:") | local lang_change = mw.ustring.match(term, "^([^%:%<]+)%:") or mw.ustring.match(term, "^(.+%>)%:") | ||
if i == 1 and lang_change == nil then error("No language code in the first parameter") end | |||
if lang_change then | |||
if i == 1 and | term = mw.ustring.sub(term, mw.ustring.len(lang_change) + 2) | ||
if lang_change | |||
local lang_args = {} | |||
code, lang_args = m_inline.parse(lang_change) | |||
-- if new language, build table | |||
if terms[code] == nil then | if terms[code] == nil then | ||
terms[code] = {} | terms[code] = {} | ||
table.insert(langs, code) | table.insert(langs, code) | ||
end | |||
current_lang = code | |||
local delim | |||
lang_args["from"], delim, current_lang = mw.ustring.match(current_lang, "^(.*)([%>%_])([^%>%_%:0-9]+)[0-9]*$") | |||
if delim and delim == ">" then lang_args["bor"] = true end | |||
-- process arguments | |||
for lang_arg, lang_val in pairs(lang_args) do | |||
terms[code][lang_arg] = lang_val | |||
end | end | ||
end | end | ||
table.insert(terms[code], term) | table.insert(terms[code], term) | ||
end | end | ||
Line 237: | Line 218: | ||
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={"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"}}) | =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", "kil<lost:oh no>:", "bal<bor>:13"}}) | ||
]]-- | ]]-- |