<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikimd.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AISO_639_name</id>
	<title>Module:ISO 639 name - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikimd.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AISO_639_name"/>
	<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:ISO_639_name&amp;action=history"/>
	<updated>2026-04-20T18:34:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=6040418&amp;oldid=prev</id>
		<title>Prab: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=6040418&amp;oldid=prev"/>
		<updated>2024-12-17T05:02:34Z</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 05:02, 17 December 2024&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>Prab</name></author>
	</entry>
	<entry>
		<id>https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=6040417&amp;oldid=prev</id>
		<title>en&gt;Trappist the monk: -temp_mod_name_get();</title>
		<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=6040417&amp;oldid=prev"/>
		<updated>2024-07-11T15:43:33Z</updated>

		<summary type="html">&lt;p&gt;-temp_mod_name_get();&lt;/p&gt;
&lt;a href=&quot;https://wikimd.com/index.php?title=Module:ISO_639_name&amp;amp;diff=6040417&amp;amp;oldid=2022940&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>en&gt;Trappist the monk</name></author>
	</entry>
	<entry>
		<id>https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=2022940&amp;oldid=prev</id>
		<title>Prab: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wikimd.com/index.php?title=Module:ISO_639_name&amp;diff=2022940&amp;oldid=prev"/>
		<updated>2020-04-12T15:28:54Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;Module:No globals&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local getArgs = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;&lt;br /&gt;
local override_data = mw.loadData (&amp;#039;Module:Language/data/ISO 639 override&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E R R O R _ M E S S A G E S &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
TODO: change to default hiding of error messages?  show with with personal css override:&lt;br /&gt;
	.show_639_err_msgs {display: inline !important;}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local error_messages = {&lt;br /&gt;
--	[&amp;#039;err_msg&amp;#039;] = &amp;#039;&amp;lt;span style=&amp;quot;font-size:100%; display:none&amp;quot; class=&amp;quot;error show_639_err_msgs&amp;quot;&amp;gt;error: $1&amp;lt;/span&amp;gt;[[Category:ISO 639 name template errors]]&amp;#039;,&lt;br /&gt;
	[&amp;#039;err_msg&amp;#039;] = &amp;#039;&amp;lt;span style=&amp;quot;font-size:100%;&amp;quot; class=&amp;quot;error show_639_err_msgs&amp;quot;&amp;gt;error: $1&amp;lt;/span&amp;gt;[[Category:ISO 639 name template errors]]&amp;#039;,&lt;br /&gt;
	[&amp;#039;err_text&amp;#039;] = {															-- error messages used only in the code to name functions&lt;br /&gt;
		[&amp;#039;ietf&amp;#039;] = &amp;#039;$1 is an IETF tag&amp;#039;,											-- $1 is the ietf tag&lt;br /&gt;
		[&amp;#039;required&amp;#039;] = &amp;#039;ISO 639$1 code is required&amp;#039;,							-- $1 is the 639 &amp;#039;-1&amp;#039;, &amp;#039;-2&amp;#039;, &amp;#039;-3&amp;#039;, &amp;#039;-5&amp;#039; part suffix; may be empty string&lt;br /&gt;
		[&amp;#039;not_code&amp;#039;] = &amp;#039;$1 is not an ISO 639$2 code&amp;#039;,							-- $1 is non-code input; $2 is 639 part suffix; may be empty string&lt;br /&gt;
&lt;br /&gt;
																				-- code to name functions and iso_639_name_to_code()&lt;br /&gt;
		[&amp;#039;not_found&amp;#039;] = &amp;#039;$1 not found in ISO 639-$2 list&amp;#039;,						-- $1 is code or language name; $2 is 639 part suffix(es)&lt;br /&gt;
&lt;br /&gt;
																				-- iso_639_name_to_code() only&lt;br /&gt;
		[&amp;#039;name&amp;#039;] = &amp;#039;language name required&amp;#039;,&lt;br /&gt;
		[&amp;#039;not_part&amp;#039;] = &amp;#039;$1 not an ISO 639 part&amp;#039;,								-- $1 is invalid 639 suffix (without hyphen)&lt;br /&gt;
		[&amp;#039;no_code&amp;#039;] = &amp;#039;no code in ISO 639-$1 for $2&amp;#039;,							-- $1 is 639 part suffix; $2 is language name&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ S E T &amp;gt;------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Returns true if argument is set; false otherwise. Argument is &amp;#039;set&amp;#039; when it exists (not nil) or when it is not an empty string.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_set( var )&lt;br /&gt;
	return not (var == nil or var == &amp;#039;&amp;#039;);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[=[-------------------------&amp;lt; M A K E _ W I K I L I N K &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only&lt;br /&gt;
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an&lt;br /&gt;
empty string.&lt;br /&gt;
&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local function make_wikilink (link, display)&lt;br /&gt;
	if is_set (link) then&lt;br /&gt;
		if is_set (display) then&lt;br /&gt;
			return table.concat ({&amp;#039;[[&amp;#039;, link, &amp;#039;|&amp;#039;, display, &amp;#039;]]&amp;#039;});&lt;br /&gt;
		else&lt;br /&gt;
			return table.concat ({&amp;#039;[[&amp;#039;, link, &amp;#039;]]&amp;#039;});&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S U B S T I T U T E &amp;gt;----------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Populates numbered arguments in a message string using an argument table.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function substitute (msg, args)&lt;br /&gt;
	return args and mw.message.newRawMessage (msg, args):plain() or msg;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E R R O R _ M S G &amp;gt;------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
create an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function error_msg (msg, arg)&lt;br /&gt;
	return substitute (error_messages.err_msg, substitute (error_messages.err_text[msg], arg))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L A N G _ N A M E _ G E T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
returns first listed language name for code from data{} table; strips parenthetical disambiguation; wikilinks to&lt;br /&gt;
the language article if link is true; returns nil else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function lang_name_get (code, data, link, label)&lt;br /&gt;
	local name;&lt;br /&gt;
	&lt;br /&gt;
	if data[code] then&lt;br /&gt;
		name = data[code][1]:gsub (&amp;#039;%s*%b()&amp;#039;, &amp;#039;&amp;#039;);								-- get the name and strip parenthetical disambiguators if any&lt;br /&gt;
		if link then															-- make a link to the language article?&lt;br /&gt;
			if name:find (&amp;#039;languages&amp;#039;) then&lt;br /&gt;
				name = make_wikilink (name, label);								-- simple wikilink for collective languages unless there is a label&lt;br /&gt;
			elseif override_data.article_name[code] then&lt;br /&gt;
				name = make_wikilink (override_data.article_name[code][1], label or name);	-- language name or label with wikilink from override data&lt;br /&gt;
			else&lt;br /&gt;
				name = make_wikilink (name .. &amp;#039; language&amp;#039;, label or name);		-- [[name language|name]] or [[name language|label]]&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return name;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; A D D _ I E T F _ E R R O R _ M S G &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
assembles return-text (language code, language name, or error message) with IETF error message into properly&lt;br /&gt;
formatted readable text&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_ietf_error_msg (text, ietf_err)&lt;br /&gt;
	return table.concat ({&lt;br /&gt;
		text,																	-- code name, language name, or error message&lt;br /&gt;
		&amp;#039;&amp;#039; ~= ietf_err and &amp;#039; &amp;#039; or &amp;#039;&amp;#039;,											-- needs a space when ietf_err is not empty&lt;br /&gt;
		ietf_err,});															-- tack on ietf error message if one exists&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; _ I S O _ 6 3 9 _ N A M E &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
searches through the ISO 639 language tables for a name that matches the supplied code.  on success returns first&lt;br /&gt;
language name that matches code from template frame perhaps with an error message and a second return value of true;&lt;br /&gt;
on failure returns the provided input text, and error message and a second return value of nil.  The second return&lt;br /&gt;
value is a return value used by iso_639_name_exists()&lt;br /&gt;
&lt;br /&gt;
looks first in the override data and then sequentially in the 639-1, -2, -3, and -5 data&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function _iso_639_name (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	if not args[1] then&lt;br /&gt;
		return error_msg (&amp;#039;required&amp;#039;, &amp;#039;&amp;#039;);										-- empty string doesn&amp;#039;t specify a 639 part (hides $1 in error message)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local code = args[1];														-- used in error messaging&lt;br /&gt;
	local lc_code;																-- holds lowercase version of code for indexing into the data tables&lt;br /&gt;
	local ietf_err;																-- holds an error message when args[1] (language code) is in IETF tag form (may or may not be a valid IETF tag)&lt;br /&gt;
	local name;																	-- the retrieved language name&lt;br /&gt;
	local data = {};															-- holds one of the various 639 code to name tables&lt;br /&gt;
	local link = &amp;#039;yes&amp;#039; == args.link;											-- make a boolean&lt;br /&gt;
&lt;br /&gt;
	code, ietf_err = code:gsub(&amp;#039;(.-)%-.*&amp;#039;, &amp;#039;%1&amp;#039;);								-- strip ietf subtags; ietf_err is non-zero when subtags are stripped&lt;br /&gt;
	lc_code = code:lower();&lt;br /&gt;
&lt;br /&gt;
	ietf_err = (0 ~= ietf_err) and error_msg (&amp;#039;ietf&amp;#039;, args[1]) or &amp;#039;&amp;#039;;			-- when tags are stripped create an error message; empty string for concatenation else&lt;br /&gt;
&lt;br /&gt;
	if 2 &amp;gt; #code or 3 &amp;lt; #code then												-- 639 codes are 2 or three characters only&lt;br /&gt;
		return  table.concat ({code, &amp;#039; &amp;#039;, error_msg (&amp;#039;not_code&amp;#039;, {code, &amp;#039;&amp;#039;})});	-- return whatever is in code + an error message; empty string hides $1&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	data = override_data.override;												-- first look in the override table&lt;br /&gt;
	name = lang_name_get (lc_code, data, link, args.label);&lt;br /&gt;
	if name then&lt;br /&gt;
		return add_ietf_error_msg (name, ietf_err), true;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if 2 == #lc_code then&lt;br /&gt;
		data = mw.loadData (&amp;#039;Module:Language/data/iana languages&amp;#039;);				-- this data used only for ISO 639-1 language codes / names listed there&lt;br /&gt;
		name = lang_name_get (lc_code, data, link, args.label);&lt;br /&gt;
		if name then&lt;br /&gt;
			return add_ietf_error_msg (name, ietf_err), true;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		for _, source in ipairs ({												-- loop sequentially through the other data tables&lt;br /&gt;
			&amp;#039;Module:Language/data/ISO 639-2&amp;#039;,&lt;br /&gt;
			&amp;#039;Module:Language/data/ISO 639-3&amp;#039;,&lt;br /&gt;
			&amp;#039;Module:Language/data/ISO 639-5&amp;#039;&lt;br /&gt;
			}) do&lt;br /&gt;
				data = mw.loadData (source);&lt;br /&gt;
				name = lang_name_get (lc_code, data, link, args.label);&lt;br /&gt;
				if name then&lt;br /&gt;
					return add_ietf_error_msg (name, ietf_err), true;&lt;br /&gt;
				end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return error_msg (&amp;#039;not_found&amp;#039;, {code, &amp;#039;1, -2, -3, -5&amp;#039;});					-- here when code is not found in the data tables&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ N A M E &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns first language name that matches code from template frame or an error message&lt;br /&gt;
looks first in the override data and then sequentially in the 639-1, -2, -3, and -5 data&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_name (frame)&lt;br /&gt;
	local ret_val = _iso_639_name (frame);										-- ignore second return value&lt;br /&gt;
	return ret_val;																-- return language name and / or error message&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ N A M E _ E X I S T S &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns true if language code maps to a language name; intended as a replacement for:&lt;br /&gt;
	{{#exist:Template:ISO 649 name &amp;lt;code&amp;gt;|&amp;lt;exists&amp;gt;|&amp;lt;doesn&amp;#039;t exist&amp;gt;}}&lt;br /&gt;
Instead of that expensive parser function call use this function:&lt;br /&gt;
	{{#if:{{#invoke:ISO 639 name|iso_639_name_exists|&amp;lt;code&amp;gt;}}|&amp;lt;exists&amp;gt;|&amp;lt;doesn&amp;#039;t exist&amp;gt;}}&lt;br /&gt;
on success, returns true; nil else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_name_exists (frame)&lt;br /&gt;
	local _, exists;&lt;br /&gt;
	 _, exists = _iso_639_name (frame);											-- ignore name/error message return; exists is true when name found for code; nil else&lt;br /&gt;
	 return exists;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ C O D E _ C O M M O N &amp;gt;----------------------------------------&lt;br /&gt;
&lt;br /&gt;
this is code that is common to all of the iso_639_code_n() functions which serve only as template entry points to&lt;br /&gt;
provide the frame, the name of the appropriate data source, and to identify which 639 part applies.&lt;br /&gt;
&lt;br /&gt;
this function returns a language name or an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_code_common (frame, source, part)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
&lt;br /&gt;
	if not args[1] then															-- if code not provided in the template call&lt;br /&gt;
		return error_msg (&amp;#039;required&amp;#039;, &amp;#039;-&amp;#039; .. part);								-- abandon&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local code;																	-- used for error messaging&lt;br /&gt;
	local ietf_err;																-- holds an error message when args[1] (language code) is in IETF tag form (may or may not be a valid IETF tag)&lt;br /&gt;
	code, ietf_err = args[1]:gsub(&amp;#039;(.-)%-.*&amp;#039;, &amp;#039;%1&amp;#039;);							-- strip ietf subtags; ietf_err is non-zero when subtags are stripped&lt;br /&gt;
	ietf_err = (0 ~= ietf_err) and error_msg (&amp;#039;ietf&amp;#039;, args[1]) or &amp;#039;&amp;#039;;			-- when tags are stripped create an error message; empty string for concatenation else&lt;br /&gt;
&lt;br /&gt;
	if (1 == part and 2 ~= #code) or (1 &amp;lt; part and 3 ~= #code) then				-- 639-1 codes are 2 characters only; all others 3 characters&lt;br /&gt;
		return  error_msg (&amp;#039;not_code&amp;#039;, {code, &amp;#039;-&amp;#039; .. part});&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local data = mw.loadData (source);											-- get the data&lt;br /&gt;
&lt;br /&gt;
	return add_ietf_error_msg (lang_name_get (code:lower(), data, args.link) or error_msg (&amp;#039;not_found&amp;#039;, {code, part}), ietf_err);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ C O D E _ 1 &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns first language name that matches ISO 639-1 code from template frame or an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_code_1 (frame)&lt;br /&gt;
	return iso_639_code_common (frame, &amp;#039;Module:Language/data/iana languages&amp;#039;, 1);	-- this data used only for ISO 639-1 language codes / names listed there&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ C O D E _ 2 &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns first language name that matches ISO 639-2 code from template frame or an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_code_2 (frame)&lt;br /&gt;
	return iso_639_code_common (frame, &amp;#039;Module:Language/data/ISO 639-2&amp;#039;, 2);	-- ISO 639-2 language codes / names&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ C O D E _ 3 &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns first language name that matches ISO 639-3 code from template frame or an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_code_3 (frame)&lt;br /&gt;
	return iso_639_code_common (frame, &amp;#039;Module:Language/data/ISO 639-3&amp;#039;, 3);	-- ISO 639-3 language codes / names&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ C O D E _ 5 &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns first language name that matches ISO 639-5 code from template frame or an error message&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_code_5 (frame)&lt;br /&gt;
	return iso_639_code_common (frame, &amp;#039;Module:Language/data/ISO 639-5&amp;#039;, 5);	-- ISO 639-5 language codes / names&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S O _ 6 3 9 _ N A M E _ T O _ C O D E &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
template entry point; returns ISO 639-1, -2, -3, or -5 code associated with language name according to part (1, 2, 3, 5) argument;&lt;br /&gt;
when part is not provided scans 1, 2, 3 , 5 and returns first code&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function iso_639_name_to_code (frame)&lt;br /&gt;
	local args = getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	if not args[1] then&lt;br /&gt;
		return error_msg (&amp;#039;name&amp;#039;);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local name = args[1];														-- used in error messaging&lt;br /&gt;
	local lc_name = name:lower();												-- holds lowercase version of name for indexing into the data table&lt;br /&gt;
&lt;br /&gt;
	local part = nil or args[2] and tonumber(args[2]);&lt;br /&gt;
	if part then&lt;br /&gt;
		if not ({&amp;#039;1&amp;#039;, &amp;#039;2&amp;#039;, &amp;#039;3&amp;#039;, nil, &amp;#039;5&amp;#039;})[part] then&lt;br /&gt;
			return error_msg (&amp;#039;not_part&amp;#039;, part);								-- part is not an ISO 639 part&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local name_data = mw.loadData (&amp;#039;Module:Language/data/ISO 639 override&amp;#039;).override;	-- first check the override data&lt;br /&gt;
	local code;																	-- place to hold the code if not a 2-character code&lt;br /&gt;
	for k, v in pairs (name_data) do											-- spin through the override table&lt;br /&gt;
		if lc_name == v[1]:lower() then											-- if name is found and&lt;br /&gt;
			if part then														-- when part specified&lt;br /&gt;
				if 1 == part then												-- if looking for part 1 codes&lt;br /&gt;
					if 2 == #k then&lt;br /&gt;
						return k;												-- return 2 char code; don&amp;#039;t care about 3 char codes here&lt;br /&gt;
					end&lt;br /&gt;
				else															-- parts 2, 3, 5&lt;br /&gt;
					if 3 == #k then&lt;br /&gt;
						return k;												-- return 3 char code&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			else																-- part not specified&lt;br /&gt;
				if 2 == #k then&lt;br /&gt;
					return k;													-- always return 2 char code when found&lt;br /&gt;
				else&lt;br /&gt;
					code = k;													-- save 3 char code in case there isn&amp;#039;t a 2 char code&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if code then																-- has a value if we found a 3-character code&lt;br /&gt;
		return code;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local name_data = mw.loadData (&amp;#039;Module:Language/data/ISO 639 name to code&amp;#039;);	-- ISO 639 language names to code table&lt;br /&gt;
&lt;br /&gt;
	if name_data[lc_name] then&lt;br /&gt;
		if part then&lt;br /&gt;
			if 5 == part then&lt;br /&gt;
				part = 4;														-- part 5 codes are at name_data[lc_name][4]; there is no part 639-4&lt;br /&gt;
			end&lt;br /&gt;
			if &amp;#039;&amp;#039; ~= name_data[lc_name][part] then&lt;br /&gt;
				return name_data[lc_name][part];&lt;br /&gt;
			else&lt;br /&gt;
				return error_msg (&amp;#039;no_code&amp;#039;, {part, name});						-- no code in ISO 639-part for language&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			for _, v in ipairs ({1, 2, 3, 5-1}) do								-- no part provided, scan through name&amp;#039;s list of codes to get the first available code&lt;br /&gt;
				if &amp;#039;&amp;#039; ~= name_data[lc_name][v] then&lt;br /&gt;
					return name_data[lc_name][v];&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return error_msg (&amp;#039;not_found&amp;#039;, {name, part or &amp;#039;1, -2, -3, -5&amp;#039;});&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	iso_639_name = iso_639_name,&lt;br /&gt;
	iso_639_name_exists = iso_639_name_exists,&lt;br /&gt;
	iso_639_code_1 = iso_639_code_1,&lt;br /&gt;
	iso_639_code_2 = iso_639_code_2,&lt;br /&gt;
	iso_639_code_3 = iso_639_code_3,&lt;br /&gt;
	iso_639_code_5 = iso_639_code_5,&lt;br /&gt;
	iso_639_name_to_code = iso_639_name_to_code,&lt;br /&gt;
	};&lt;/div&gt;</summary>
		<author><name>Prab</name></author>
	</entry>
</feed>