<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ro">
	<id>https://enciclopedia.md/index.php?action=history&amp;feed=atom&amp;title=Modul%3ALocationAndCountry</id>
	<title>Modul:LocationAndCountry - Revizia istoricului</title>
	<link rel="self" type="application/atom+xml" href="https://enciclopedia.md/index.php?action=history&amp;feed=atom&amp;title=Modul%3ALocationAndCountry"/>
	<link rel="alternate" type="text/html" href="https://enciclopedia.md/index.php?title=Modul:LocationAndCountry&amp;action=history"/>
	<updated>2026-04-22T00:39:45Z</updated>
	<subtitle>Istoricul versiunilor pentru această pagină din wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://enciclopedia.md/index.php?title=Modul:LocationAndCountry&amp;diff=348&amp;oldid=prev</id>
		<title>Sergiu: Pagină nouă: -- will display a wikidata property representing a location, followed by a comma and the name of the country, both with wikilinks -- the first argument specifies the parameter to be displayed -- the second argument specifies the entity ID -- the third argument specifies a timestamp showing the moment in time for which the country is to be identified -- the fourth argument specifies the maximum number of values to be processed (default 1) -- the fifth argument specifies the se...</title>
		<link rel="alternate" type="text/html" href="https://enciclopedia.md/index.php?title=Modul:LocationAndCountry&amp;diff=348&amp;oldid=prev"/>
		<updated>2024-07-14T20:23:25Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: -- will display a wikidata property representing a location, followed by a comma and the name of the country, both with wikilinks -- the first argument specifies the parameter to be displayed -- the second argument specifies the entity ID -- the third argument specifies a timestamp showing the moment in time for which the country is to be identified -- the fourth argument specifies the maximum number of values to be processed (default 1) -- the fifth argument specifies the se...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pagină nouă&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- will display a wikidata property representing a location, followed by a comma and the name of the country, both with wikilinks&lt;br /&gt;
-- the first argument specifies the parameter to be displayed&lt;br /&gt;
-- the second argument specifies the entity ID&lt;br /&gt;
-- the third argument specifies a timestamp showing the moment in time for which the country is to be identified&lt;br /&gt;
-- the fourth argument specifies the maximum number of values to be processed (default 1)&lt;br /&gt;
-- the fifth argument specifies the separator to use when displaying multiple values&lt;br /&gt;
local getArgs = require(&amp;#039;Modul:Arguments&amp;#039;).getArgs&lt;br /&gt;
local Wikidata = require(&amp;#039;Modul:Wikidata&amp;#039;)&lt;br /&gt;
local lacData = mw.loadData(&amp;#039;Modul:LocationAndCountry/data&amp;#039;)&lt;br /&gt;
local TableTools = require(&amp;#039;Modul:TableTools&amp;#039;)&lt;br /&gt;
local GregorianDate = require(&amp;#039;Modul:GregorianDate&amp;#039;)&lt;br /&gt;
local DateUtils = require(&amp;#039;Modul:DateUtils&amp;#039;)&lt;br /&gt;
local Set = require(&amp;#039;Modul:Set&amp;#039;)&lt;br /&gt;
local illWd = require(&amp;#039;Modul:Ill-wd&amp;#039;).fromArgs&lt;br /&gt;
local Transliteration = require(&amp;#039;Modul:Transliteration&amp;#039;)&lt;br /&gt;
local getValueByTimestamp = require(&amp;#039;Modul:TimestampedTable&amp;#039;).getValueByTimestamp&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function getClaimsForParam(entity, param)&lt;br /&gt;
	local claims = nil&lt;br /&gt;
	local workingEntityId = nil&lt;br /&gt;
	if type(entity) == &amp;#039;table&amp;#039; then&lt;br /&gt;
		workingEntityId = entity.id&lt;br /&gt;
		claims = entity:getBestStatements(param)&lt;br /&gt;
	else&lt;br /&gt;
		workingEntityId = entity&lt;br /&gt;
		if not workingEntityId then workingEntityId = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
		if type(entity) == &amp;#039;number&amp;#039; then workingEntityId = &amp;#039;Q&amp;#039; .. tostring(entity) end&lt;br /&gt;
		if workingEntityId == nil then return &amp;#039;&amp;#039; end&lt;br /&gt;
		claims = mw.wikibase.getBestStatements(workingEntityId, param)&lt;br /&gt;
	end&lt;br /&gt;
	return claims, workingEntityId&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getTimestamp(timestamp, workingEntityId)&lt;br /&gt;
	local ts = nil&lt;br /&gt;
	if timestamp then&lt;br /&gt;
		if type(timestamp) == &amp;#039;string&amp;#039; and mw.ustring.gmatch(timestamp, &amp;#039;P%d+&amp;#039;) then&lt;br /&gt;
			local wdDates = Wikidata.findDateValues(timestamp, workingEntityId)&lt;br /&gt;
			if wdDates then for _,eachWdDate in ipairs(wdDates) do&lt;br /&gt;
				if Wikidata.isClaimTrue(eachWdDate.claim) and Wikidata.hasValueSnak(eachWdDate.claim) then&lt;br /&gt;
					ts = GregorianDate.convertToGregorianIfInInterval(eachWdDate)&lt;br /&gt;
					break&lt;br /&gt;
				end&lt;br /&gt;
			end end&lt;br /&gt;
		end&lt;br /&gt;
		if ts == nil and type(timestamp) == &amp;#039;string&amp;#039; and mw.ustring.match(timestamp, &amp;#039;^%d+&amp;#039;) then&lt;br /&gt;
			ts = DateUtils.parseYear(timestamp)&lt;br /&gt;
		elseif ts == nil and type(timestamp) == &amp;#039;table&amp;#039; and timestamp.year then&lt;br /&gt;
			ts = timestamp&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getUatsAndCountryFromQuals(claim)&lt;br /&gt;
	if not Wikidata.isClaimTrue(claim) or not claim.qualifiers then return nil end&lt;br /&gt;
	local country = nil&lt;br /&gt;
	local uats = {}&lt;br /&gt;
	if claim.qualifiers[&amp;#039;P17&amp;#039;] then for _,eachCountryQual in ipairs(claim.qualifiers[&amp;#039;P17&amp;#039;]) do&lt;br /&gt;
		if Wikidata.isValueSnak(eachCountryQual) then&lt;br /&gt;
			country = eachCountryQual.datavalue.value.id&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end end&lt;br /&gt;
	&lt;br /&gt;
	if claim.qualifiers[&amp;#039;P131&amp;#039;] then for _,eachUatQual in ipairs(claim.qualifiers[&amp;#039;P131&amp;#039;]) do&lt;br /&gt;
		if Wikidata.isValueSnak(eachUatQual) then&lt;br /&gt;
			table.insert(uats, eachUatQual.datavalue.value.id)&lt;br /&gt;
		end&lt;br /&gt;
	end end&lt;br /&gt;
	&lt;br /&gt;
	return uats, country&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getClaimForTimestamp(entityId, propId, ts)&lt;br /&gt;
	local timestampedClaim = Wikidata.findClaimForTimestamp(entityId, propId, ts)&lt;br /&gt;
	if timestampedClaim and Wikidata.hasValueSnak(timestampedClaim) then&lt;br /&gt;
		local retVal = timestampedClaim&lt;br /&gt;
		local claimTs = nil&lt;br /&gt;
		if timestampedClaim.qualifiers and timestampedClaim.qualifiers[&amp;#039;P582&amp;#039;] then&lt;br /&gt;
			for _,endTQual in ipairs(timestampedClaim.qualifiers[&amp;#039;P582&amp;#039;]) do if Wikidata.isValueSnak(endTQual) then&lt;br /&gt;
				claimTs = GregorianDate.convertToGregorianIfInInterval(DateUtils.extractDateFromWikidataSnak(endTQual))&lt;br /&gt;
				break&lt;br /&gt;
			end end&lt;br /&gt;
		end&lt;br /&gt;
		return retVal, claimTs&lt;br /&gt;
	end&lt;br /&gt;
	return nil, nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getCountryIdForTimestamp(entityId, ts)&lt;br /&gt;
	local countryClaim, retTs = getClaimForTimestamp(entityId, &amp;#039;P17&amp;#039;, ts)&lt;br /&gt;
&lt;br /&gt;
	if countryClaim and Wikidata.hasValueSnak(countryClaim) then&lt;br /&gt;
		return countryClaim.mainsnak.datavalue.value.id, retTs&lt;br /&gt;
	else&lt;br /&gt;
		return Wikidata.loadOneValueInChain({entityId, &amp;#039;P17&amp;#039;, &amp;#039;raw&amp;#039;}), nil&lt;br /&gt;
	end&lt;br /&gt;
end	&lt;br /&gt;
&lt;br /&gt;
-- returns 0, 1 or 2 - the number of admin units to be pulled&lt;br /&gt;
local function shouldPullUats(entityId, countryId)&lt;br /&gt;
	-- villages, rural settlements, should get 2 uats&lt;br /&gt;
	if Wikidata.isA(entityId, lacData.adminUnitExpandableLocationTypes) then&lt;br /&gt;
		return 2&lt;br /&gt;
	end&lt;br /&gt;
	-- locations in federal countries should get at least one UAT regardless of size&lt;br /&gt;
	if countryId and (Wikidata.isA(countryId, { &amp;#039;Q22676603&amp;#039;, &amp;#039;Q43702&amp;#039; })&lt;br /&gt;
		or TableTools.contains(lacData.adminUnitExpandableCountries, countryId)) then&lt;br /&gt;
		return 1&lt;br /&gt;
	end&lt;br /&gt;
	-- only big cities should have just the country&lt;br /&gt;
	if not Wikidata.isA(entityId, {&amp;#039;Q1549591&amp;#039;, &amp;#039;Q1637706&amp;#039;, &amp;#039;Q200250&amp;#039;}) then&lt;br /&gt;
		return 1&lt;br /&gt;
	end&lt;br /&gt;
	return 0&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function recurseUats(entityId, ts)&lt;br /&gt;
	local crtUatId = entityId&lt;br /&gt;
	local crtCountryId = Wikidata.loadOneValueInChain({entityId, &amp;#039;P17&amp;#039;, &amp;#039;raw&amp;#039;})&lt;br /&gt;
	local timestampedCountryId = getCountryIdForTimestamp(entityId, ts)&lt;br /&gt;
	local uatList = {}&lt;br /&gt;
	while crtUatId and crtUatId ~= crtCountryId and crtUatId ~= timestampedCountryId do&lt;br /&gt;
		local timestampedUatClaim = Wikidata.findClaimForTimestamp(crtUatId, &amp;#039;P131&amp;#039;, ts)&lt;br /&gt;
		crtUatId = timestampedUatClaim and Wikidata.hasValueSnak(timestampedUatClaim) and timestampedUatClaim.mainsnak.datavalue.value.id or Wikidata.loadOneValueInChain({crtUatId, &amp;#039;P131&amp;#039;, &amp;#039;raw&amp;#039;})&lt;br /&gt;
		if (TableTools.contains(uatList, crtUatId)) then&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(uatList, crtUatId)&lt;br /&gt;
	end&lt;br /&gt;
	local uatListCountryId = nil&lt;br /&gt;
	if #uatList &amp;gt; 0 and (uatList[#uatList] == crtCountryId or uatList[#uatList] == timestampedCountryId or Wikidata.isA(uatList[#uatList], {&amp;#039;Q6256&amp;#039;})) then&lt;br /&gt;
		uatListCountryId  = table.remove(uatList, #uatList)&lt;br /&gt;
	end&lt;br /&gt;
	return uatList, uatListCountryId&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function shouldSkipLocation(entityId)&lt;br /&gt;
	return Wikidata.isA(entityId, lacData.escalatableLocationTypes)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function trimUats(uatList)&lt;br /&gt;
	while #uatList &amp;gt; 0 and (Wikidata.isA(uatList[1], lacData.skippableUatTypes) or TableTools.contains(lacData.skippableUats, uatList[1])) do&lt;br /&gt;
		table.remove(uatList, 1)&lt;br /&gt;
	end&lt;br /&gt;
	while #uatList &amp;gt; 0 and (Wikidata.isA(uatList[#uatList], lacData.skippableUatTypes) or TableTools.contains(lacData.skippableUats, uatList[#uatList])) do&lt;br /&gt;
		table.remove(uatList, #uatList)&lt;br /&gt;
	end&lt;br /&gt;
	return uatList&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function resolvePartName(partId, ts, crtCountryId, uats)&lt;br /&gt;
	if lacData.locationNameOverrides[partId] then&lt;br /&gt;
&lt;br /&gt;
		local timestampedLabel = getValueByTimestamp(lacData.locationNameOverrides[partId], ts)&lt;br /&gt;
		return illWd(partId, timestampedLabel)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local offLangCodes = { &amp;#039;ro&amp;#039; }&lt;br /&gt;
	local offLangSource = nil&lt;br /&gt;
	local countryId = getCountryIdForTimestamp(partId, ts)&lt;br /&gt;
	&lt;br /&gt;
	if TableTools.contains(lacData.invariantLocations, partId) or&lt;br /&gt;
		(crtCountryId and TableTools.contains(lacData.invariantLocationCountries, crtCountryId))&lt;br /&gt;
		or TableTools.size(Set.valueIntersection(recurseUats(partId), lacData.invariantLocationUats)) &amp;gt; 0&lt;br /&gt;
		or Wikidata.isA(partId, lacData.invariantLocationTypes) then&lt;br /&gt;
		offLangCodes = { &amp;#039;ro&amp;#039; }&lt;br /&gt;
	else&lt;br /&gt;
		-- look for (1) official language of the location&lt;br /&gt;
		local officialLangAtTsClaim = getClaimForTimestamp(partId, &amp;#039;P37&amp;#039;, ts)&lt;br /&gt;
		local officialLangClaims = officialLangAtTsClaim and { officialLangAtTsClaim } or Wikidata.findBestClaimsForProperty(partId, &amp;#039;P37&amp;#039;)&lt;br /&gt;
		--          (2) official language of one of the UATs&lt;br /&gt;
		if not officialLangClaims or #officialLangClaims == 0 then&lt;br /&gt;
			for uatIdx,eachUat in ipairs(uats or {}) do&lt;br /&gt;
				local uatOfficialLangAtTsClaim = getClaimForTimestamp(eachUat, &amp;#039;P37&amp;#039;, ts)&lt;br /&gt;
				local uatOfficialLangClaims = uatOfficialLangAtTsSnak and {uatOfficialLangAtTsClaim } or Wikidata.findBestClaimsForProperty(eachUat, &amp;#039;P37&amp;#039;)&lt;br /&gt;
				if not officialLangClaims or #officialLangClaims == 0 then&lt;br /&gt;
					officialLangClaims = uatOfficialLangClaims&lt;br /&gt;
					offLangSource = { qId = eachUat, srcType = &amp;#039;uat&amp;#039;, srcIdx = uatIdx }&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			offLangSource = { qId = partId, srcType = &amp;#039;part&amp;#039; }&lt;br /&gt;
		end&lt;br /&gt;
		--          (3) official language of the country&lt;br /&gt;
		if not officialLangClaims or #officialLangClaims == 0 then&lt;br /&gt;
			if not countryId then return illWd(partId) end&lt;br /&gt;
			officialLangClaims = Wikidata.findBestClaimsForProperty(countryId, &amp;#039;P37&amp;#039;)&lt;br /&gt;
			offLangSource = { qId = countryId, srcType = &amp;#039;country&amp;#039; }&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		for _,eachOffLangClaim in ipairs(officialLangClaims) do&lt;br /&gt;
			if Wikidata.hasValueSnak(eachOffLangClaim) and (not eachOffLangClaim.qualifiers or not eachOffLangClaim.qualifiers[&amp;#039;P518&amp;#039;]) then&lt;br /&gt;
				local eachOffLangId = eachOffLangClaim.mainsnak.datavalue.value.id&lt;br /&gt;
				local writingSystemQueue = Wikidata.getBestEntityIdsList(eachOffLangId, &amp;#039;P282&amp;#039;)&lt;br /&gt;
				local writingSystem = writingSystemQueue and table.remove(writingSystemQueue, 1)&lt;br /&gt;
				while writingSystem and writingSystem ~= &amp;#039;&amp;#039; and writingSystem ~= 8229 do&lt;br /&gt;
					TableTools.appendAll(writingSystemQueue, Wikidata.getBestEntityIdsList(writingSystem, &amp;#039;P282&amp;#039;))&lt;br /&gt;
					writingSystem = table.remove(writingSystemQueue, 1)&lt;br /&gt;
				end&lt;br /&gt;
				local offLangCode = Wikidata.loadOneValueInChain({eachOffLangId, &amp;#039;P218&amp;#039;})&lt;br /&gt;
				if offLangCode and offLangCode ~= &amp;#039;&amp;#039; then&lt;br /&gt;
					if writingSystem == 8229 or Transliteration.isTransliterationSupported(offLangCode) then&lt;br /&gt;
						table.insert(offLangCodes, offLangCode)&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #offLangCodes &amp;gt; 1 and offLangSource then&lt;br /&gt;
		--search config order&lt;br /&gt;
		local configOrder = lacData.languageOrder[offLangSource.qId]&lt;br /&gt;
		if offLangSource.srcType == &amp;#039;part&amp;#039; or offLangSource.srcType == &amp;#039;uat&amp;#039; then&lt;br /&gt;
			local startIdx = offLangSource.srcType == &amp;#039;uat&amp;#039; and offLangSource.srcIdx or 1&lt;br /&gt;
			local crtIdx = startIdx&lt;br /&gt;
			while not configOrder and crtIdx &amp;lt;= #(uats or {}) do&lt;br /&gt;
				configOrder = configOrder or lacData.languageOrder[uats[crtIdx]]&lt;br /&gt;
				crtIdx = crtIdx + 1&lt;br /&gt;
			end&lt;br /&gt;
			configOrder = configOrder or lacData.languageOrder[countryId]&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if configOrder then&lt;br /&gt;
			local sortedOffLangCodes = {}&lt;br /&gt;
			local unknownOffLangCodes = {}&lt;br /&gt;
			for _,eachLang in ipairs(configOrder) do&lt;br /&gt;
				if TableTools.contains(offLangCodes, eachLang) then&lt;br /&gt;
					table.insert(sortedOffLangCodes, eachLang)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			for _,eachLang in ipairs(offLangCodes) do&lt;br /&gt;
				if not TableTools.contains(sortedOffLangCodes, eachLang) then&lt;br /&gt;
					table.insert(sortedOffLangCodes, eachLang)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			offLangCodes = sortedOffLangCodes&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	for _,offLangCode in ipairs(offLangCodes) do&lt;br /&gt;
		local wdPropForName = Wikidata.isA(partId, lacData.shortNameLocationTypes) and &amp;#039;P1813&amp;#039; or &amp;#039;P1448&amp;#039;&lt;br /&gt;
		&lt;br /&gt;
		local officialNameClaim = Wikidata.findClaimForTimestamp(partId, wdPropForName, ts, offLangCode)&lt;br /&gt;
		if officialNameClaim and Wikidata.isClaimTrue(officialNameClaim) and Wikidata.hasValueSnak(officialNameClaim) then&lt;br /&gt;
			local nameInOffLang = officialNameClaim.mainsnak.datavalue.value.text&lt;br /&gt;
			if wdPropForName == &amp;#039;P1448&amp;#039; and (not officialNameClaim.qualifiers or not officialNameClaim.qualifiers[&amp;#039;P582&amp;#039;]) then -- if this is a former name, use it&lt;br /&gt;
			-- if this is the current name, then just get the label from that language&lt;br /&gt;
				nameInOffLang = mw.wikibase.getLabelByLang(partId, offLangCode)&lt;br /&gt;
			end&lt;br /&gt;
			return illWd(partId, Transliteration.isTransliterationSupported(offLangCode) and Transliteration.transliterate(nameInOffLang, offLangCode) or nameInOffLang)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	for _,offLangCode in ipairs(offLangCodes) do&lt;br /&gt;
		local labelInLang = Wikidata.findLabel(partId, offLangCode)&lt;br /&gt;
		if Transliteration.isTransliterationSupported(offLangCode) then&lt;br /&gt;
			labelInLang = Transliteration.transliterate(labelInLang, offLangCode)&lt;br /&gt;
		end&lt;br /&gt;
		return illWd(partId, labelInLang)&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function resolvePartNames(partIds, ts, crtCountryId, uats)&lt;br /&gt;
	if not partIds then return nil end&lt;br /&gt;
	local res = {}&lt;br /&gt;
	for _,partId in ipairs(partIds) do&lt;br /&gt;
		table.insert(res, resolvePartName(partId, ts, crtCountryId, uats))&lt;br /&gt;
	end&lt;br /&gt;
	return res&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function collapseCapitalledUat(locationEntityId, uatEntitiesIds)&lt;br /&gt;
	if not uatEntitiesIds or #uatEntitiesIds == 0 then return uatEntitiesIds end&lt;br /&gt;
	local out = {}&lt;br /&gt;
	local firstUatEntCapital = Wikidata.loadOneValueInChain({uatEntitiesIds[1], &amp;#039;P36&amp;#039;, &amp;#039;raw&amp;#039;})&lt;br /&gt;
	if not firstUatEntCapital or firstUatEntCapital ~= locationEntityId then&lt;br /&gt;
		table.insert(out, uatEntitiesIds[1])&lt;br /&gt;
	end&lt;br /&gt;
	for idx = 2,#uatEntitiesIds do table.insert(out, uatEntitiesIds[idx]) end&lt;br /&gt;
	return out&lt;br /&gt;
		&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function displayFromParams(param, entity, timestamp, maxvalues, separator, enableRefs)&lt;br /&gt;
&lt;br /&gt;
	if param == nil then return &amp;#039;&amp;#039; end&lt;br /&gt;
	&lt;br /&gt;
	local claims, workingEntityId = getClaimsForParam(entity, param)&lt;br /&gt;
&lt;br /&gt;
	local ts = getTimestamp(timestamp, workingEntityId)&lt;br /&gt;
&lt;br /&gt;
	local valueList = {}&lt;br /&gt;
	local maxvalues = maxvalues or 1&lt;br /&gt;
	if claims and 0 &amp;lt; #claims then&lt;br /&gt;
		for _,actualClaim in ipairs(claims) do&lt;br /&gt;
			local uatEntitiesIds = {}&lt;br /&gt;
			local countryId = nil&lt;br /&gt;
			local locationEntityId = nil&lt;br /&gt;
			if Wikidata.isClaimTrue(actualClaim) and Wikidata.hasValueSnak(actualClaim) then&lt;br /&gt;
				-- get admin unit(s) and/or country from qualifiers&lt;br /&gt;
				uatEntitiesIds, countryId = getUatsAndCountryFromQuals(actualClaim)&lt;br /&gt;
				locationEntityId = actualClaim.mainsnak.datavalue.value.id&lt;br /&gt;
				local countryByTs, countryTs = getCountryIdForTimestamp(locationEntityId, ts)&lt;br /&gt;
&lt;br /&gt;
				countryId = countryId or countryByTs&lt;br /&gt;
				-- (1) see if admin unit needs to be pulled&lt;br /&gt;
				local uatsEnabled = shouldPullUats(locationEntityId, countryId)&lt;br /&gt;
				-- (2) pull all admin units based on timestamp until reaching nothing, self or country&lt;br /&gt;
				local allUats, uatCountryId = recurseUats(locationEntityId, ts)&lt;br /&gt;
				if uatsEnabled &amp;gt; 0 then&lt;br /&gt;
					if uatCountryId and uatCountryId ~= countryId and not countryTs then&lt;br /&gt;
						countryId = uatCountryId&lt;br /&gt;
					elseif countryTs and uatCountryId and uatCountryId ~= countryId then&lt;br /&gt;
						allUats = {}&lt;br /&gt;
					end&lt;br /&gt;
					-- (3) if the location itself is to be skipped, keep the first admin unit in the list as location&lt;br /&gt;
					while #allUats &amp;gt; 0 and shouldSkipLocation(locationEntityId) do&lt;br /&gt;
						locationEntityId = table.remove(allUats, 1)&lt;br /&gt;
					end&lt;br /&gt;
					-- (4) apply rules to eliminate from both ends&lt;br /&gt;
					local trimmedUats = trimUats(allUats)&lt;br /&gt;
					-- (5) keep only first and last (or the only one if only one is left)&lt;br /&gt;
					uatEntitiesIds = #trimmedUats == 0 and {} or #trimmedUats == 1 and trimmedUats or uatsEnabled == 1 and {trimmedUats[#trimmedUats]} or {trimmedUats[1], trimmedUats[#trimmedUats]}&lt;br /&gt;
					if #uatEntitiesIds &amp;gt; 1 then&lt;br /&gt;
						uatEntitiesIds = collapseCapitalledUat(locationEntityId, uatEntitiesIds)&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					uatEntitiesIds = {}&lt;br /&gt;
				end&lt;br /&gt;
				local allPartIds = {}&lt;br /&gt;
				table.insert(allPartIds, locationEntityId)&lt;br /&gt;
				for __,eachUat in ipairs(uatEntitiesIds) do table.insert(allPartIds, eachUat) end&lt;br /&gt;
				local allPartLinks = resolvePartNames(allPartIds, ts, Wikidata.loadOneValueInChain({locationEntityId, &amp;#039;P17&amp;#039;, &amp;#039;raw&amp;#039;}), allUats)&lt;br /&gt;
				if not countryId and uatEntitiesIds and #uatEntitiesIds &amp;gt; 0 then&lt;br /&gt;
					countryId = Wikidata.loadOneValueInChain({uatEntitiesIds[#uatEntitiesIds], &amp;#039;P17&amp;#039;, &amp;#039;raw&amp;#039;})&lt;br /&gt;
				end&lt;br /&gt;
				if countryId and not TableTools.contains(allPartIds, countryId)&lt;br /&gt;
					and not Wikidata.isA(#uatEntitiesIds &amp;gt; 0 and uatEntitiesIds[#uatEntitiesIds] or locationEntityId, lacData.skipCountryTypes) then&lt;br /&gt;
					table.insert(allPartLinks, lacData.countryNameOverrides[countryId] and illWd(countryId, lacData.countryNameOverrides[countryId]) or resolvePartName(countryId, ts, countryId))&lt;br /&gt;
				end&lt;br /&gt;
				local crtVal = table.concat(allPartLinks, &amp;#039;, &amp;#039;)&lt;br /&gt;
				if enableRefs then crtVal = crtVal .. Wikidata.outputReferences(actualClaim) end&lt;br /&gt;
				table.insert(valueList, crtVal)&lt;br /&gt;
			end&lt;br /&gt;
			if #valueList &amp;gt;= maxvalues then&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(valueList, separator or &amp;#039;; &amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
p.displayFromParams = displayFromParams&lt;br /&gt;
&lt;br /&gt;
local function displayFromArgs(args)&lt;br /&gt;
	local param = nil&lt;br /&gt;
	local entity = nil&lt;br /&gt;
	local timestamp = nil&lt;br /&gt;
	local maxvalues = 1&lt;br /&gt;
	local separator = &amp;#039;; &amp;#039;&lt;br /&gt;
	if args[1] or args[&amp;#039;param&amp;#039;] then&lt;br /&gt;
		param = args[1] or args[&amp;#039;param&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	if args[2] or args[&amp;#039;entityId&amp;#039;] then&lt;br /&gt;
		entity = args[2] or args[&amp;#039;entityId&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	if args[3] or args[&amp;#039;timestamp&amp;#039;] then&lt;br /&gt;
		timestamp = args[3] or args[&amp;#039;timestamp&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	if args[4] or args[&amp;#039;maxvalues&amp;#039;] then&lt;br /&gt;
		maxvalues = tonumber(args[4] or args[&amp;#039;maxvalues&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
	if args[5] or args[&amp;#039;separator&amp;#039;] then&lt;br /&gt;
		separator = args[5] or args[&amp;#039;separator&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	return displayFromParams(param, entity, timestamp, maxvalues, separator)&lt;br /&gt;
end&lt;br /&gt;
p.displayFromArgs = displayFromArgs&lt;br /&gt;
&lt;br /&gt;
p.displayFromFrame = function(frame)&lt;br /&gt;
	local args = getArgs(frame, { frameOnly = true })&lt;br /&gt;
	return displayFromArgs(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.displayFromParentFrame = function(frame)&lt;br /&gt;
	local args = getArgs(frame, { parentOnly = true})&lt;br /&gt;
	return displayFromArgs(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Sergiu</name></author>
	</entry>
</feed>