Module:I18n/objects

local wikidata_label = require('Module:Wikidata label')._getLabel local LookupTable = mw.loadData('Module:I18n/objects/data')

local p = {}

function p.simpleObject(object, lang) local wikitext = '' local item = LookupTable[string.lower(object)] -- try to find an item in the dictionary if item then -- if an item was found use it		wikitext = wikidata_label(item, lang) elseif object and object ~= '' then -- set maintenance category and fall back to the input string wikitext = '' .. object end return wikitext, item end

function p._object(object, relObject, lang) local relText, relItem, relQs local wikitext, mainItem = p.simpleObject(object, lang) if relObject and relObject ~= '' then relText, relItem = p.simpleObject(relObject, lang) wikitext = string.format('%s (%s)', wikitext, relText) end -- create non-visible language independent marking in QuickStatements-like format local qsText = '' local qs = '' if mainItem then if relItem then relQs = ',P642,' .. relItem -- property "of" (P642), as a qualifier to P31 else relQs = '' end qsText = ' object_type QS:P31,' .. mainItem .. relQs .. ' '		 -- property "instance of" (P31) end return wikitext .. qsText end

function p.object(frame) local args = frame.args return p._object(args.object, args.relObject, args.lang) end

return p