<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATitle</id>
	<title>Module:Title - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ATitle"/>
	<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Title&amp;action=history"/>
	<updated>2026-05-04T13:31:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Title&amp;diff=24363&amp;oldid=prev</id>
		<title>Kurt: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Title&amp;diff=24363&amp;oldid=prev"/>
		<updated>2022-10-23T22:34:45Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:34, 23 October 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Kurt</name></author>
	</entry>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Title&amp;diff=24362&amp;oldid=prev</id>
		<title>commons&gt;Jarekt: restore getArgs function</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Title&amp;diff=24362&amp;oldid=prev"/>
		<updated>2022-03-01T04:56:21Z</updated>

		<summary type="html">&lt;p&gt;restore getArgs function&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[  &lt;br /&gt;
  __  __           _       _       _____ _ _   _      &lt;br /&gt;
 |  \/  | ___   __| |_   _| | ___ |_   _(_) |_| | ___ &lt;br /&gt;
 | |\/| |/ _ \ / _` | | | | |/ _ (_)| | | | __| |/ _ \&lt;br /&gt;
 | |  | | (_) | (_| | |_| | |  __/_ | | | | |_| |  __/&lt;br /&gt;
 |_|  |_|\___/ \__,_|\__,_|_|\___(_)|_| |_|\__|_|\___|&lt;br /&gt;
                                                                             &lt;br /&gt;
This module is intended to be the engine behind &amp;quot;Template:Title&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Authors and maintainers:&lt;br /&gt;
* User:Jarekt - original version &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
require('Module:No globals') -- used for debugging purposes as it detects cases of unintended global variables&lt;br /&gt;
local core      = require('Module:Core')&lt;br /&gt;
local createTag = require('Module:TagQS').createTag&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === Internal functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
------------------------------------------------------------------------------&lt;br /&gt;
-- Clone of core.getArgs except for adding args.lang&lt;br /&gt;
-- Based on frame structure create &amp;quot;args&amp;quot; table with all the input parameters.&lt;br /&gt;
-- All inputs are not not case-sensitive and underscored are treated the same &lt;br /&gt;
-- way as speces. Input values are trimmed and empty string are converted to &lt;br /&gt;
-- nils. &lt;br /&gt;
local function getArgs(frame)&lt;br /&gt;
	local function normalize_input_args(input_args, output_args)&lt;br /&gt;
		for name, value in pairs( input_args ) do &lt;br /&gt;
			if type(name)=='string' and value ~= '' then &lt;br /&gt;
				output_args[string.lower(name)] = value&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return output_args&lt;br /&gt;
	end&lt;br /&gt;
	local args = {}&lt;br /&gt;
	args = normalize_input_args(frame:getParent().args, args)&lt;br /&gt;
	args = normalize_input_args(frame.args, args)&lt;br /&gt;
	return args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ====================================================================&lt;br /&gt;
local function style(str, textLang)&lt;br /&gt;
-- based on [[Template:Title/style]]&lt;br /&gt;
	if not str or #str==0 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	str = mw.text.trim(str)&lt;br /&gt;
	local LUT = {ar='%s',he='%s' ,et='„%s“' ,ja='『%s』' ,mk='„%s“' ,ru='«%s»' ,zh='《%s》', ['zh-hans']='《%s》', en='&amp;lt;i&amp;gt;%s&amp;lt;/i&amp;gt;'}&lt;br /&gt;
	--str = mw.language:ucfirst(str)&lt;br /&gt;
	local form = core.langSwitchWithLang(LUT, textLang)&lt;br /&gt;
	str = mw.ustring.format( form,  str) -- place quotes&lt;br /&gt;
	local dir = mw.language.new( textLang ):getDir()&lt;br /&gt;
    str = string.format('&amp;lt;span dir=&amp;quot;%s&amp;quot; lang=&amp;quot;%s&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', dir, textLang, str)&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
-- === get wikidata item ID (qid) based on P6243 stored in SDC             ===&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
local function qid_from_SDC()&lt;br /&gt;
	local page = mw.title.getCurrentTitle()&lt;br /&gt;
	if page.namespace==6 then -- File namespace&lt;br /&gt;
		local entity = mw.wikibase.getEntity()&lt;br /&gt;
		if entity and entity.statements and entity.statements.P6243 then&lt;br /&gt;
			local statement = entity.statements.P6243[1]&lt;br /&gt;
			return statement.mainsnak.datavalue.value.id&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ====================================================================&lt;br /&gt;
local function harvest_wikidata(entity, userLang)&lt;br /&gt;
	local data = {} -- structure similar to &amp;quot;args&amp;quot; but filled with wikidata data&lt;br /&gt;
	data.userLang = userLang&lt;br /&gt;
	if not entity then&lt;br /&gt;
		return data&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- get title (from 3 properties and label)&lt;br /&gt;
	local property = {P1476 = 'title', P1448='official_name', P1705='native_label'}&lt;br /&gt;
	for prop, field in pairs( property ) do&lt;br /&gt;
		local titleList = {}&lt;br /&gt;
		for _, statement in pairs( entity:getBestStatements(field)) do &lt;br /&gt;
			if (statement.mainsnak.snaktype == &amp;quot;value&amp;quot;) then &lt;br /&gt;
				local val = statement.mainsnak.datavalue.value&lt;br /&gt;
				titleList[val.language] = val.text -- look for multiple values each with a language code&lt;br /&gt;
				data.title, data.lang = val.text, val.language -- in case we have title in some odd language: capture it&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if #titleList&amp;gt;1 then&lt;br /&gt;
			local title, language = core.langSwitch(titleList, userLang)&lt;br /&gt;
			if title then&lt;br /&gt;
				data.title, data.lang = title, language&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if data.title then&lt;br /&gt;
			data.title = data.title .. core.editAtWikidata(entity.id, prop, userLang)&lt;br /&gt;
			break -- title found so no need for other property&lt;br /&gt;
		end	&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- get labels in all the langguages&lt;br /&gt;
	if entity.labels then&lt;br /&gt;
		for _, val in pairs(entity.labels) do -- loop over all labels&lt;br /&gt;
			if val.language~=data.lang then&lt;br /&gt;
				data[val.language] = val.value&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function quote(str)&lt;br /&gt;
	return '&amp;quot;' .. str .. '&amp;quot;'&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ==================================================&lt;br /&gt;
-- === External functions ===========================&lt;br /&gt;
-- ==================================================&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
-- === Version of the function to be called from other LUA codes&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
function p.title_(args)&lt;br /&gt;
	local line1, line2, Title, text, lang&lt;br /&gt;
	local colon   = mw.message.new( &amp;quot;colon&amp;quot; ):inLanguage(args.userLang ):plain()&lt;br /&gt;
	local wordsep = mw.message.new( &amp;quot;Word-separator&amp;quot; ):inLanguage(args.userLang ):plain()&lt;br /&gt;
	local qsTable = {}&lt;br /&gt;
&lt;br /&gt;
	if args.lang and args.title then -- == Case 1: original language to be displayed ==&lt;br /&gt;
		args.lang = string.lower(args.lang)&lt;br /&gt;
		line1 = style(args.title, args.lang) -- first line&lt;br /&gt;
		if args.lang==args.userLang then -- user's language = title's language&lt;br /&gt;
			Title = mw.ustring.format( '&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', line1 or '')&lt;br /&gt;
		else -- user's language != title's language&lt;br /&gt;
			-- line 1 original language &lt;br /&gt;
			local langName = mw.language.fetchLanguageName( args.lang, args.userLang  )&lt;br /&gt;
			line1 = langName .. colon .. wordsep .. line1 -- add language name to line #1&lt;br /&gt;
			if args.transliteration then &lt;br /&gt;
				line1 = line1 .. '&amp;amp;#32;- '  .. args.transliteration&lt;br /&gt;
			end&lt;br /&gt;
			line1 = mw.ustring.format( '&amp;lt;span style=&amp;quot;font-size:0.9em&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', line1)&lt;br /&gt;
&lt;br /&gt;
			--  line 2 translation&lt;br /&gt;
			if args.translation then &lt;br /&gt;
				line2 = args.translation&lt;br /&gt;
			else&lt;br /&gt;
				text, lang = core.langSwitchWithLang(args, args.userLang)&lt;br /&gt;
				line2 = style(text, lang)&lt;br /&gt;
			end&lt;br /&gt;
			if line2 then&lt;br /&gt;
				line2 = mw.ustring.format( '&amp;lt;br/&amp;gt;&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', line2)&lt;br /&gt;
			end &lt;br /&gt;
			Title = line1 .. (line2 or '')&lt;br /&gt;
		end&lt;br /&gt;
		if not args.title_ then -- make sure title did not originated on wikidata&lt;br /&gt;
			table.insert( qsTable, createTag('title', 'P1476', args.lang .. ':' .. quote(args.title)) )&lt;br /&gt;
			table.insert( qsTable, createTag('label', 'L'..args.lang, quote(args.title)) )&lt;br /&gt;
		end&lt;br /&gt;
	else -- == Case 2: original language not relevant ==&lt;br /&gt;
		if args.title then &lt;br /&gt;
			Title = mw.ustring.format( '&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', args.title )&lt;br /&gt;
		else&lt;br /&gt;
			text, lang = core.langSwitchWithLang(args, args.userLang)&lt;br /&gt;
			if text then&lt;br /&gt;
				Title = style(text, lang)&lt;br /&gt;
				Title = mw.ustring.format( '&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;%s&amp;lt;/span&amp;gt;', Title)&lt;br /&gt;
			else -- list them all &lt;br /&gt;
				local Titles = {}			&lt;br /&gt;
				for lang, text in pairs(args) do&lt;br /&gt;
					if type(lang)=='string' and  mw.language.isSupportedLanguage( lang ) then&lt;br /&gt;
						local langName = mw.language.fetchLanguageName( lang, args.userLang  )&lt;br /&gt;
						table.insert(Titles, langName .. colon .. wordsep .. style(text, lang) )&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				Title = table.concat(Titles, '\n')&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	Title = Title or ''&lt;br /&gt;
	if args.comment then&lt;br /&gt;
		Title = mw.ustring.format( '%s&amp;lt;br /&amp;gt;&amp;lt;span style=&amp;quot;font-size:0.9em&amp;quot;&amp;gt;%s&amp;lt;br /&amp;gt;&amp;lt;/span&amp;gt;', title, args.comment)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add text of invisible tag brodcasted by the template which allows creation of QuickStatements command used to add this info to Wikidata&lt;br /&gt;
	for lang, text in pairs( args ) do &lt;br /&gt;
		if type(lang)=='string' and mw.language.isSupportedLanguage(lang) and not args[lang..'_'] then -- lang has tobe a valid language and the statement is not from wikidata&lt;br /&gt;
			table.insert( qsTable, createTag('label', 'L'..lang, quote(text)) )&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return Title .. table.concat( qsTable, '\n')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.wikidata_title(entity, userLang)&lt;br /&gt;
	return p.title_(harvest_wikidata(entity, userLang))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
-- === Versions of the function to be called from template namespace&lt;br /&gt;
-- ===========================================================================&lt;br /&gt;
function p.title(frame)&lt;br /&gt;
	-- args.lang is usually provided and it is used for the language of the title&lt;br /&gt;
	-- not customary language of the user which can be provided by args.userlang&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	args.userLang = args.userlang&lt;br /&gt;
	if not (args.userLang and mw.language.isSupportedLanguage(args.userLang)) then &lt;br /&gt;
		args.userLang = frame:callParserFunction( &amp;quot;int&amp;quot;, &amp;quot;lang&amp;quot; ) -- get user's chosen language&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
	-- merge wikidata with local variables&lt;br /&gt;
	local qid = args.wikidata or qid_from_SDC() -- get wikidata item ID based on P6243 stored in SDC&lt;br /&gt;
	if qid then &lt;br /&gt;
		local entity = mw.wikibase.getEntity(qid)&lt;br /&gt;
		if entity then&lt;br /&gt;
			local data = harvest_wikidata(entity, args.userLang)&lt;br /&gt;
			if not args.title and data.title and not args.lang and data.lang then&lt;br /&gt;
				args.title = data.title -- get title from wikidata&lt;br /&gt;
				args.lang  = data.lang&lt;br /&gt;
				args.title_ = 'from wikidata'&lt;br /&gt;
			end&lt;br /&gt;
			for lang, text in pairs( data ) do &lt;br /&gt;
				if mw.language.isSupportedLanguage(lang) and not args[lang] then &lt;br /&gt;
					args[lang] = text&lt;br /&gt;
					args[lang..'_'] = 'from wikidata'&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return p.title_(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>commons&gt;Jarekt</name></author>
	</entry>
</feed>