Difference between revisions of "Module:LiteratureData"

From En JW United
Jump to navigation Jump to search
(Created page with "local p = {} function p.getPublicationDateBasedOnLanguage(param) result = 'information not available on data.jwunited.org for ' .. param.args[1] names = mw.wikibase.getBest...")
 
Line 5: Line 5:
 
names = mw.wikibase.getBestStatements( param.args[1], 'P6' )
 
names = mw.wikibase.getBestStatements( param.args[1], 'P6' )
 
for i, name in ipairs(names) do
 
for i, name in ipairs(names) do
qualifier = name['qualifiers']
 
lang = '';
 
if (qualifier ~= nil)
 
then lang = name['qualifiers']['P5'][1]['datavalue']['value']
 
end
 
if (lang == param.args[2])
 
then
 
 
result = name['mainsnak']['datavalue']['value']['time']
 
result = name['mainsnak']['datavalue']['value']['time']
end
 
 
end
 
end
 
return result
 
return result

Revision as of 04:01, 23 October 2019

Documentation for this module may be created at Module:LiteratureData/doc

local p = {}

function p.getPublicationDateBasedOnLanguage(param)
	result = 'information not available on data.jwunited.org for ' .. param.args[1]
	names = mw.wikibase.getBestStatements( param.args[1], 'P6' )
	for i, name in ipairs(names) do
		result = name['mainsnak']['datavalue']['value']['time']
	end
	return result
end

function p.getNameOfLiteratureBasedOnLanguage(param)
	result = 'information not available on data.jwunited.org for ' .. param.args[1]
	names = mw.wikibase.getBestStatements( param.args[1], 'P2' )
	for i, name in ipairs(names) do
		qualifier = name['qualifiers']
		lang = '';
		if (qualifier ~= nil)
			then lang = name['qualifiers']['P5'][1]['datavalue']['value']
		end
	if (lang == param.args[2])
	then
		result = name['mainsnak']['datavalue']['value']
	end
	end
	return result
end

return p