Module:RootFinder
From The Seven Sages of Rome
Documentation for this module may be created at Module:RootFinder/doc
local p = {}
-- Function to recursively find the root language
function p.findRootLanguage(language)
-- Query to get the "Is Variety Of" value for the given language
local query = string.format('[[%s]]|?Is Variety Of', language)
-- Execute the query using mw.smw.ask
local result = mw.smw.ask(query)
-- If there's a result (i.e., the language has a "Is Variety Of" value)
if result and result[1] and result[1].values and result[1].values["Is Variety Of"] then
-- Recursively call the function with the parent language
return p.findRootLanguage(result[1].values["Is Variety Of"])
else
-- Return the current language if it doesn't have a "Is Variety Of" value
return language
end
end
return p