localexport={}localSystem={}functionSystem:getCode()returnself._codeendfunctionSystem:getCanonicalName()returnself._rawData.canonicalNameendfunctionSystem:getOtherNames()returnself._rawData.otherNamesor{}end--function System:getAllNames()-- return self._rawData.names--end--[==[Given a list of types as strings, returns true if the script has all of them. Possible types are explained in [[Module:scripts/data]].]==]functionSystem:hasType(...)ifnotself._typethenself._type={["writing system"]=true}ifself._rawData.typethenfor_,typeinipairs(mw.text.split(self._rawData.type,"%s*,%s*"))doself._type[type]=trueendendendfor_,typeinipairs{...}doifnotself._type[type]thenreturnfalseendendreturntrueendfunctionSystem:getCategoryName()--return self._rawData.category or mw.getContentLanguage():ucfirst(self:getCanonicalName() .. "s")returnself._rawData.categoryormw.getContentLanguage():ucfirst(self:getCanonicalName())endfunctionSystem:getRawData()returnself._rawDataendfunctionSystem:toJSON()ifnotself._typethenself:hasType()endlocaltypes={}fortypeinpairs(self._type)dotable.insert(types,type)endlocalret={canonicalName=self:getCanonicalName(),categoryName=self:getCategoryName(),code=self:getCode(),otherNames=self:getOtherNames(),type=types,}returnrequire("Module:JSON").toJSON(ret)endSystem.__index=Systemfunctionexport.makeObject(code,data)returndataandsetmetatable({_rawData=data,_code=code},System)ornilendfunctionexport.getByCode(code)returnexport.makeObject(code,mw.loadData("Module:writing systems/data")[code])endreturnexport