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 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)
-- Debugging: Output the structure of the result to help diagnose the problem
mw.log("Query result: " .. mw.text.jsonEncode(result))
-- Check if we received a valid result
if result and result[1] and result[1].values then
-- Check if the "Is Variety Of" value exists
local parentLanguage = result[1].values["Is Variety Of"]
-- If there's a parent language, recursively find its root
if parentLanguage then
return p.findRootLanguage(parentLanguage)
else
-- Return the current language if no parent is found
return language
end
else
-- If no valid result, return the original language
return language
end
end
return p