Module:NarratorListModule: Difference between revisions
From The Seven Sages of Rome
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p._findRoot(language) | |||
function p. | local current = language | ||
-- | while true do | ||
-- Query for the 'Is Variety Of' property of the current language | |||
local results = mw.smw.ask({ | |||
'[[Category:Language]]', | |||
'[[' .. current .. ']]', | |||
'?Is Variety Of' | |||
}) | |||
-- Exit if no results or invalid response | |||
if not results or #results == 0 then break end | |||
-- | -- Extract parent data from the first result | ||
local parentData = results[1]['Is Variety Of'] | |||
-- Exit if no parent found | |||
if not parentData or #parentData == 0 then break end | |||
-- Move to the parent language (using fulltext for page name) | |||
current = parentData[1].fulltext | |||
end | end | ||
return current | |||
end | |||
-- | function p.main(frame) | ||
return language | local language = frame.args[1] -- Get input language from template | ||
return p._findRoot(language) | |||
end | end | ||
return p | return p | ||
Revision as of 13:21, 25 March 2025
Documentation for this module may be created at Module:NarratorListModule/doc
local p = {}
function p._findRoot(language)
local current = language
while true do
-- Query for the 'Is Variety Of' property of the current language
local results = mw.smw.ask({
'[[Category:Language]]',
'[[' .. current .. ']]',
'?Is Variety Of'
})
-- Exit if no results or invalid response
if not results or #results == 0 then break end
-- Extract parent data from the first result
local parentData = results[1]['Is Variety Of']
-- Exit if no parent found
if not parentData or #parentData == 0 then break end
-- Move to the parent language (using fulltext for page name)
current = parentData[1].fulltext
end
return current
end
function p.main(frame)
local language = frame.args[1] -- Get input language from template
return p._findRoot(language)
end
return p