-- Transclusion-based tracking as subpages of [[Wiktionary:Tracking]].-- Tracked pages can be found at [[Special:WhatLinksHere/Wiktionary:Tracking/KEY]].localerror=errorlocalfind=string.findlocalmakeTitle=mw.title.makeTitlelocalsub=string.sublocaltype=typelocalmemo={}localfunctiontrack(key)-- Return if memoized.ifmemo[key]thenreturnend-- Throw an error if `key` isn't a string.localkey_type=type(key)ifkey_type~="string"thenerror("Tracking keys supplied to [[Module:debug/track]] must be strings; received "..key_type..".",3)end-- makeTitle returns nil for invalid titles, but "#" is treated as a-- fragment separator (e.g. "foo#bar" generates the title "foo"), so we-- need to manually exclude it.localtitle=notfind(key,"#",1,true)andmakeTitle(4,"Tracking/"..key)iftitlethen-- Normalize the key, by getting title.text and removing the initial-- "Tracking/". Normally this will be the same as title.subpageText,-- but subpageText will be wrong if there are further slashes, so we-- can't use it.localnormalized=sub(title.text,10)-- Return if the normalized form has been memoized.ifmemo[normalized]thenreturnend-- Otherwise, transclude the page. Getting the raw page content is the-- fastest way to trigger transclusion, as it avoids any parser-- expansion of the target page.title:getContent()-- Memoize normalized form.memo[normalized]=trueelse-- Track uses of invalid keys. Replace with error message once all have-- been eliminated.-- [[Special:WhatLinksHere/Wiktionary:Tracking/debug/track/invalid key]]track("debug/track/invalid key")-- error("Tracking key \"" .. key .. "\" supplied to [[Module:debug/track]] is invalid: key must be a [[mw:Help:Bad title|valid page name]].", 3)endmemo[key]=trueendreturnfunction(input)ifinput==nilthenerror("No tracking key supplied to [[Module:debug/track]].",2)elseiftype(input)~="table"thentrack(input)returntrueendlocalkey=input[1]ifkey==nilthenerror("No tracking keys in table supplied to [[Module:debug/track]].",2)endlocali=1repeattrack(key)i=i+1key=input[i]untilkey==nilreturntrueend