Module:I18n

-- This Module is used for making templates based in the Lua language. -- See more details about Lua in Help:Lua. -- The Fandom Developer's Wiki hosts Global Lua Modules that can be imported and locally overridden. -- The next line imports the I18n module from the w:c:dev:Global Lua Modules. local i18n = require('Dev:I18n') -- See more details about this module at w:c:dev:Global_Lua_Modules/I18n

-- The code below add an addition `msgRev` function to get get massage code from text local oldLoad = i18n.loadMessages i18n.loadMessages = function(...) ds = oldLoad(...) local Data = getmetatable(ds) function Data:msgRev(opts, ...) local frame = mw.getCurrentFrame -- Argument normalization. if not self or not opts then error('missing arguments in Data:msg') end local key = type(opts) == 'table' and opts.key or opts local args = opts.args or {...} -- Configuration parameters. if opts.sources then self:fromSources(unpack(opts.sources)) end if opts.lang then self:inLang(opts.lang) end -- Source handling. local source_n = self.tempSources or self._sources local source_i = {} for n, i in pairs(source_n) do           source_i[i] = n        end self.tempSources = nil -- Language handling. local lang = self.tempLang or self.defaultLang self.tempLang = nil -- Message fetching. local msg for i, messages in ipairs(self._messages) do           -- Message data. for k, v in pairs(messages[lang] or {}) do               if v == key then if args.prefix == nil or mw.ustring.find(k, args.prefix) ~= nil then return k                   end end end end return mw.text.nowiki('<' .. key .. '>') end setmetatable(ds, Data) return ds end -- The last line produces the output for the template return i18n