Module:NarratorListModule
From The Seven Sages of Rome
Documentation for this module may be created at Module:NarratorListModule/doc
local p = {}
-- Function to recursively find the root language
function p.findRootLanguage(language)
-- Query parameters
local query = {
conditions = string.format('[[%s]]', language),
printouts = { 'Is Variety Of' }
}
-- Execute the query
local result = mw.smw.getQueryResult(query)
-- Debugging: Log the result structure
mw.log("Query result: " .. mw.text.jsonEncode(result))
-- Check if we received a valid result
if result and result.results then
for _, pageData in pairs(result.results) do
local parentLanguage = pageData.printouts["Is Variety Of"]
if parentLanguage and #parentLanguage > 0 then
return p.findRootLanguage(parentLanguage[1].fulltext) -- Recursively find the root language
end
end
end
-- If no parent is found, return the current language (this is the root language)
return language
end
return p