Module:Translations

local p = {} local h = {}

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

local CATEGORY_INVALID_ARGS = ""

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=Translations2",				args = {					game = game,					subject = subject,					term = term,					lang = lang,					translation = translation,					meaning = meaning,					ref = ref				}			}) 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*$", "") return arg end function h.warn(msg, ...) local utilsError = require("Module:UtilsError") msg = string.format(msg, ...) utilsError.warn(msg) end

return p