Module:I18n

local p = {}

local data, _ = mw.title.new('MediaWiki:Custom-Common/i18n.json'):getContent:gsub('^%s*//[^\n]*\n', '') data = require('Module:Json').decode(data) local title = mw.title.getCurrentTitle

function p.msg(frame) local lang = 'en' local msg = frame.args[1] if title.isSubpage then local text = title.subpageText -- Check if language exists if mw.language.fetchLanguageName(text) ~= '' then lang = text end end -- TODO: Better fallback system with Module:Fallbacklist local msgData = data[lang] or data.en   local msg = msgData[msg] or data.en[msg] if msg then return msg else return '\'\'\'Message not found.\'\'\'' end end

return p