Module:RootFinder: Difference between revisions
From The Seven Sages of Rome
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
while true do | while true do | ||
local | local query = "[[" .. language .. "]]|?" .. parent_prop | ||
local result = mw.smw.ask{ query } | |||
if result and result[language] and result[language][parent_prop] then | if result and result[language] and result[language][parent_prop] then | ||
language = result[language][parent_prop] | language = result[language][parent_prop] | ||
Revision as of 10:37, 25 March 2025
Documentation for this module may be created at Module:RootFinder/doc
local p = {}
local function get_root_language(language)
local parent_prop = "Is Variety Of"
while true do
local query = "[[" .. language .. "]]|?" .. parent_prop
local result = mw.smw.ask{ query }
if result and result[language] and result[language][parent_prop] then
language = result[language][parent_prop]
else
break
end
end
return language
end
function p.tree(frame)
local current_language = mw.title.getCurrentTitle().text
local root_language = get_root_language(current_language)
local query = string.format(
'[[%s]] [[Category:Language]] |format=tree |parent=Is Variety Of |limit=5000',
root_language
)
return frame:preprocess('{{#ask:' .. query .. '}}')
end
return p