<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages%2Fprint</id>
	<title>Module:languages/print - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages%2Fprint"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:languages/print&amp;action=history"/>
	<updated>2026-04-07T10:56:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:languages/print&amp;diff=477615&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  local byte = string.byte local concat = table.concat local escape = require(&quot;Module:debug/escape&quot;) local format = string.format local highlight = require(&quot;Module:debug&quot;).highlight local insert = table.insert local pairs = pairs local require = require local sorted_pairs = require(&quot;Module:table&quot;).sortedPairs local toJSON = require(&quot;Module:JSON&quot;).toJSON  local function iterate_data(func, module_name) 	for code, data in pairs(require(module_name)) do 		fu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:languages/print&amp;diff=477615&amp;oldid=prev"/>
		<updated>2025-11-15T15:18:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local byte = string.byte local concat = table.concat local escape = require(&amp;quot;Module:debug/escape&amp;quot;) local format = string.format local highlight = require(&amp;quot;Module:debug&amp;quot;).highlight local insert = table.insert local pairs = pairs local require = require local sorted_pairs = require(&amp;quot;Module:table&amp;quot;).sortedPairs local toJSON = require(&amp;quot;Module:JSON&amp;quot;).toJSON  local function iterate_data(func, module_name) 	for code, data in pairs(require(module_name)) do 		fu...&amp;quot;&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;
local byte = string.byte&lt;br /&gt;
local concat = table.concat&lt;br /&gt;
local escape = require(&amp;quot;Module:debug/escape&amp;quot;)&lt;br /&gt;
local format = string.format&lt;br /&gt;
local highlight = require(&amp;quot;Module:debug&amp;quot;).highlight&lt;br /&gt;
local insert = table.insert&lt;br /&gt;
local pairs = pairs&lt;br /&gt;
local require = require&lt;br /&gt;
local sorted_pairs = require(&amp;quot;Module:table&amp;quot;).sortedPairs&lt;br /&gt;
local toJSON = require(&amp;quot;Module:JSON&amp;quot;).toJSON&lt;br /&gt;
&lt;br /&gt;
local function iterate_data(func, module_name)&lt;br /&gt;
	for code, data in pairs(require(module_name)) do&lt;br /&gt;
		func(code, data)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function for_code_and_data(func, module_type)&lt;br /&gt;
	if module_type == &amp;quot;language&amp;quot; then&lt;br /&gt;
		iterate_data(func, &amp;quot;Module:languages/data/2&amp;quot;)&lt;br /&gt;
		for b = byte(&amp;quot;a&amp;quot;), byte(&amp;quot;z&amp;quot;) do&lt;br /&gt;
			iterate_data(func, format(&amp;quot;Module:languages/data/3/%c&amp;quot;, b))&lt;br /&gt;
		end&lt;br /&gt;
		iterate_data(func, &amp;quot;Module:languages/data/exceptional&amp;quot;)&lt;br /&gt;
	elseif module_type == &amp;quot;etymology&amp;quot; then&lt;br /&gt;
		iterate_data(func, &amp;quot;Module:etymology languages/data&amp;quot;)&lt;br /&gt;
	elseif module_type == &amp;quot;family&amp;quot; then&lt;br /&gt;
		iterate_data(func, &amp;quot;Module:families/data&amp;quot;)&lt;br /&gt;
	elseif module_type == &amp;quot;script&amp;quot; then&lt;br /&gt;
		iterate_data(func, &amp;quot;Module:scripts/data&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function dump_string(s)&lt;br /&gt;
	return format(&amp;#039;&amp;quot;%s&amp;quot;&amp;#039;, escape(s, &amp;quot;double&amp;quot;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function dump_table(data)&lt;br /&gt;
	local output, i = {&amp;quot;return {&amp;quot;}, 1&lt;br /&gt;
&lt;br /&gt;
	for k, v in sorted_pairs(data) do&lt;br /&gt;
		i = i + 1&lt;br /&gt;
		output[i] = format(&amp;quot;\t[%s] = %s,&amp;quot;, dump_string(k), dump_string(v))&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	insert(output, &amp;quot;}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	return concat(output, &amp;quot;\n&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function print_data(t, output)&lt;br /&gt;
	if output == &amp;quot;plain&amp;quot; then&lt;br /&gt;
		return dump_table(t)&lt;br /&gt;
	elseif output == &amp;quot;json&amp;quot; then&lt;br /&gt;
		return toJSON(t, {compress = true, sort_keys = true})&lt;br /&gt;
	end&lt;br /&gt;
	return highlight(dump_table(t))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.code_to_name(frame)&lt;br /&gt;
	local args, result = frame.args, {}&lt;br /&gt;
	for_code_and_data(function(code, data)&lt;br /&gt;
		result[code] = data[1]&lt;br /&gt;
	end, args[2])&lt;br /&gt;
	return print_data(result, args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.name_to_code(frame)&lt;br /&gt;
	local args, result = frame.args, {}&lt;br /&gt;
	local langtype, get_obj = args[2]&lt;br /&gt;
&lt;br /&gt;
	if langtype == &amp;quot;script&amp;quot; then&lt;br /&gt;
		get_obj = require(&amp;quot;Module:scripts&amp;quot;).getByCode&lt;br /&gt;
	else&lt;br /&gt;
		local get_lang = require(&amp;quot;Module:languages&amp;quot;).getByCode&lt;br /&gt;
		function get_obj(code)&lt;br /&gt;
			return get_lang(code, nil, true, true)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	for_code_and_data(function(code, data)&lt;br /&gt;
		local name = data[1]&lt;br /&gt;
		local current = result[name]&lt;br /&gt;
		if not current then&lt;br /&gt;
			result[name] = code&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
		-- Sometimes, multiple scripts have the same name, e.g. &amp;quot;Arab&amp;quot;,&lt;br /&gt;
		-- &amp;quot;fa-Arab&amp;quot;, &amp;quot;ur-Arab&amp;quot; and several others are called &amp;quot;Arabic&amp;quot;. Prefer&lt;br /&gt;
		-- the senior code.&lt;br /&gt;
		local check = get_obj(current)&lt;br /&gt;
		while check do&lt;br /&gt;
			if check:getCode() == code then&lt;br /&gt;
				result[name] = code&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
			check = check:getParent()&lt;br /&gt;
		end&lt;br /&gt;
	end, langtype)&lt;br /&gt;
	return print_data(result, args[1])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.appendix_constructed_canonical_names()&lt;br /&gt;
	local names = {}&lt;br /&gt;
	for_code_and_data(function(_, data)&lt;br /&gt;
		if data.type == &amp;quot;appendix-constructed&amp;quot; then&lt;br /&gt;
			insert(names, data[1])&lt;br /&gt;
		end&lt;br /&gt;
	end, &amp;quot;language&amp;quot;)&lt;br /&gt;
	require(&amp;quot;Module:collation&amp;quot;).sort(names)&lt;br /&gt;
	return toJSON(names, {compress = true})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>