<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://youjo.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ALanguage-like</id>
	<title>Module:Language-like - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://youjo.wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ALanguage-like"/>
	<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Language-like&amp;action=history"/>
	<updated>2026-10-17T17:53:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://youjo.wiki/index.php?title=Module:Language-like&amp;diff=1404&amp;oldid=prev</id>
		<title>Chizu: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Language-like&amp;diff=1404&amp;oldid=prev"/>
		<updated>2022-09-23T19:42:07Z</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;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:42, 23 September 2022&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key youjowiki:diff::1.12:old-1403:rev-1404 --&gt;
&lt;/table&gt;</summary>
		<author><name>Chizu</name></author>
	</entry>
	<entry>
		<id>https://youjo.wiki/index.php?title=Module:Language-like&amp;diff=1403&amp;oldid=prev</id>
		<title>Wiktionary&gt;Surjection: prefer self._extraData over self._rawData if available. will be useful for later, see Wiktionary:Beer parlour/2021/July#Reducing the size of Module:languages/data* by moving varieties/aliases/other names (and possibly Wikidata links) elsewhere</title>
		<link rel="alternate" type="text/html" href="https://youjo.wiki/index.php?title=Module:Language-like&amp;diff=1403&amp;oldid=prev"/>
		<updated>2021-08-08T12:40:47Z</updated>

		<summary type="html">&lt;p&gt;prefer self._extraData over self._rawData if available. will be useful for later, see &lt;a href=&quot;https://en.wiktionary.org/wiki/Beer_parlour/2021/July#Reducing_the_size_of_Module:languages.2Fdata.2A_by_moving_varieties.2Faliases.2Fother_names_.28and_possibly_Wikidata_links.29_elsewhere&quot; class=&quot;extiw&quot; title=&quot;wiktionary:Beer parlour/2021/July&quot;&gt;Wiktionary:Beer parlour/2021/July#Reducing the size of Module:languages/data* by moving varieties/aliases/other names (and possibly Wikidata links) elsewhere&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local export = {}&lt;br /&gt;
&lt;br /&gt;
-- Implementation of getOtherNames() for languages, etymology languages,&lt;br /&gt;
-- families and scripts. If `onlyOtherNames` is passed in, only return&lt;br /&gt;
-- the names in the `otherNames` field, otherwise combine `otherNames`,&lt;br /&gt;
-- `aliases` and `varieties`.&lt;br /&gt;
function export.getOtherNames(self, onlyOtherNames)&lt;br /&gt;
	local data&lt;br /&gt;
	if self._extraData then&lt;br /&gt;
		data = self._extraData&lt;br /&gt;
	else&lt;br /&gt;
		data = self._rawData&lt;br /&gt;
	end&lt;br /&gt;
	if onlyOtherNames then&lt;br /&gt;
		return data.otherNames or {}&lt;br /&gt;
	end&lt;br /&gt;
	-- Combine otherNames, aliases and varieties. First try to optimize and not create any&lt;br /&gt;
	-- new memory. This is possible if exactly one of the three exist, and if it&amp;#039;s `varieties`,&lt;br /&gt;
	-- there are no nested lists in `varieties`.&lt;br /&gt;
	if data.otherNames and not data.aliases and not data.varieties then&lt;br /&gt;
		return data.otherNames&lt;br /&gt;
	elseif data.aliases and not data.otherNames and not data.varieties then&lt;br /&gt;
		return data.aliases&lt;br /&gt;
	elseif data.varieties and not data.otherNames and not data.aliases then&lt;br /&gt;
		local saw_table = false&lt;br /&gt;
		for _, name in ipairs(data.varieties) do&lt;br /&gt;
			if type(name) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				saw_table = true&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not saw_table then&lt;br /&gt;
			return data.varieties&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Have to do it the &amp;quot;hard way&amp;quot;.&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	if data.otherNames then&lt;br /&gt;
		for _, name in ipairs(data.otherNames) do&lt;br /&gt;
			table.insert(ret, name)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if data.aliases then&lt;br /&gt;
		for _, name in ipairs(data.aliases) do&lt;br /&gt;
			table.insert(ret, name)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if data.varieties then&lt;br /&gt;
		for _, name in ipairs(data.varieties) do&lt;br /&gt;
			if type(name) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				for _, n in ipairs(name) do&lt;br /&gt;
					table.insert(ret, n)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				table.insert(ret, name)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Implementation of getVarieties() for languages, etymology languages,&lt;br /&gt;
-- families and scripts. If `flatten` is passed in, flatten down to a&lt;br /&gt;
-- list of stings; otherwise, keep the structure.&lt;br /&gt;
function export.getVarieties(self, flatten)&lt;br /&gt;
	local data&lt;br /&gt;
	if self._extraData then&lt;br /&gt;
		data = self._extraData&lt;br /&gt;
	else&lt;br /&gt;
		data = self._rawData&lt;br /&gt;
	end&lt;br /&gt;
	if data.varieties then&lt;br /&gt;
		-- If flattening not requested, just return them.&lt;br /&gt;
		if not flatten then&lt;br /&gt;
			return data.varieties&lt;br /&gt;
		end&lt;br /&gt;
		-- Check if no nested table; if so, just return the result.&lt;br /&gt;
		local saw_table = false&lt;br /&gt;
		for _, name in ipairs(data.varieties) do&lt;br /&gt;
			if type(name) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				saw_table = true&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not saw_table then&lt;br /&gt;
			return data.varieties&lt;br /&gt;
		end&lt;br /&gt;
		-- At this point, we need to flatten the varieties.&lt;br /&gt;
		local ret = {}&lt;br /&gt;
		for _, name in ipairs(data.varieties) do&lt;br /&gt;
			if type(name) == &amp;quot;table&amp;quot; then&lt;br /&gt;
				for _, n in ipairs(name) do&lt;br /&gt;
					table.insert(ret, n)&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				table.insert(ret, name)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return ret&lt;br /&gt;
	else&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Implementation of template-callable getByCode() function for languages,&lt;br /&gt;
-- etymology languages, families and scripts. `item` is the language,&lt;br /&gt;
-- family or script in question; `args` is the arguments passed in by the&lt;br /&gt;
-- module invocation; `extra_processing`, if specified, is a function of&lt;br /&gt;
-- one argument (the requested property) and should return the value to&lt;br /&gt;
-- be returned to the caller, or nil if the property isn&amp;#039;t recognized.&lt;br /&gt;
-- `extra_processing` is called after special-cased properties are handled&lt;br /&gt;
-- and before general-purpose processing code that works for all string&lt;br /&gt;
-- properties.&lt;br /&gt;
function export.templateGetByCode(item, args, extra_processing)&lt;br /&gt;
	-- The item that the caller wanted to look up&lt;br /&gt;
	local itemname = args[2] or error(&amp;quot;Function to call (parameter 2) has not been specified.&amp;quot;)&lt;br /&gt;
	local list&lt;br /&gt;
	if itemname == &amp;quot;getOtherNames&amp;quot; then&lt;br /&gt;
		list = item:getOtherNames()&lt;br /&gt;
	elseif itemname == &amp;quot;getOnlyOtherNames&amp;quot; then&lt;br /&gt;
		list = item:getOtherNames(true)&lt;br /&gt;
	elseif itemname == &amp;quot;getAliases&amp;quot; then&lt;br /&gt;
		list = item:getAliases()&lt;br /&gt;
	elseif itemname == &amp;quot;getVarieties&amp;quot; then&lt;br /&gt;
		list = item:getVarieties(true)&lt;br /&gt;
	end&lt;br /&gt;
	if list then&lt;br /&gt;
		local index = args[3]; if index == &amp;quot;&amp;quot; then index = nil end&lt;br /&gt;
		index = tonumber(index or error(&amp;quot;Numeric index of the desired item in the list (parameter 3) has not been specified.&amp;quot;))&lt;br /&gt;
		return list[index] or &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if itemname == &amp;quot;getFamily&amp;quot; and item.getFamily then&lt;br /&gt;
		return item:getFamily():getCode()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if extra_processing then&lt;br /&gt;
		local retval = extra_processing(itemname)&lt;br /&gt;
		if retval then&lt;br /&gt;
			return retval&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if item[itemname] then&lt;br /&gt;
		local ret = item[itemname](item)&lt;br /&gt;
		&lt;br /&gt;
		if type(ret) == &amp;quot;string&amp;quot; then&lt;br /&gt;
			return ret&lt;br /&gt;
		else&lt;br /&gt;
			error(&amp;quot;The function \&amp;quot;&amp;quot; .. itemname .. &amp;quot;\&amp;quot; did not return a string value.&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	error(&amp;quot;Requested invalid item name \&amp;quot;&amp;quot; .. itemname .. &amp;quot;\&amp;quot;.&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Wiktionary&gt;Surjection</name></author>
	</entry>
</feed>