Module:Translations

local p = {} local h = {}

local LanguageData = mw.loadData("Module:Language/Data") local Term = require("Module:Term")

p.Templates = mw.loadData("Module:Translations/TemplateData")

local CATEGORY_INVALID_ARGS = ""

function p.Boilerplate(frame) local Language = require("Module:Language") local lines = {"{{Translation/Store||"} for i, lang in ipairs(Language.enum) do		local line = string.format("|%s= |%sM= |%sR= ", lang, lang, lang) table.insert(lines, line) end table.insert(lines, "}}") local boilerplate = table.concat(lines, "\n") return string.format(" %s ", boilerplate) end

function p.Store(frame) local frameArgs = frame:getParent.args local game = h.parseArg(frameArgs[1]) local subject = h.parseArg(frameArgs[2])

local hasErrors = false if game == nil or game == "" then hasErrors = true h.warn(" parameter is required") end if subject == nil or subject == "" then hasErrors = true h.warn(" parameter is required") end if hasErrors then return CATEGORY_INVALID_ARGS end for lang in pairs(LanguageData.lects) do		local translation = h.parseArg(frameArgs[lang]) if translation ~= "" then local term = Term.fetchTerm(subject, "Series") or subject local meaning = h.parseArg(frameArgs[lang.."M"]) local ref = h.parseArg(frameArgs[lang.."R"]) frame:callParserFunction({				name = "#cargo_store:_table=Translations",				args = {					game = game,					subject = subject,					term = term,					lang = lang,					translation = translation,					meaning = meaning,					ref = ref				}			}) -- we render references on the data page so that pages with invalid refs show up in the invalid args category if ref and ref ~= "" then frame:extensionTag("ref", ref) end end end end

function h.parseArg(arg) if not arg then return "" end -- trim any leading and trailing whitespace arg = string.gsub(arg, "^%s*", "") arg = string.gsub(arg, "%s*$", "") arg = mw.text.killMarkers(arg) return arg end function h.warn(msg, ...) local utilsError = require("Module:UtilsError") msg = string.format(msg, ...) utilsError.warn(msg) end

return p