Module:Tr

local VariablesLua = mw.ext.VariablesLua

-- local isOnWiki = mw.loadData('Module:Tr/onWikiList') -- return { -- load database for template:tr -- from template: loadData = function(frame) local lang = frame.args['lang'] or 'en' local database = mw.loadData( 'Module:Tr/loaddata-'..lang) local prefix = '_tr:'..lang ..':' for k,v in pairs(database.main) do			VariablesLua.vardefine( prefix..k, v ) end prefix = prefix .. 'link:' for k,v in pairs(database.pagename) do			VariablesLua.vardefine( prefix..k, v ) end end, -- purge database cache -- from template: -- from module: require('Module:tr').purge purge = function(frame) local lang if frame == mw.getCurrentFrame then lang = frame.args['lang'] else lang = frame end lang = lang or 'en' require('Module:Tr/loaddata').purge(lang) end,

-- for other module. Functionally identical to. translateLink = function(input, lang) local database = mw.loadData('Module:Tr/loaddata-'..lang) local t = database.pagename[input] if not t then -- is onWiki? if isOnWiki[lang] then t = input..'/'..lang -- / else t = database.main[input] or input -- use as fallback end end return t	end, -- for other module. Functionally identical to. translate = function(input, lang) local database = mw.loadData('Module:Tr/loaddata-'..lang) return database.main[input] or input end, }