<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.nordiclarp.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ALang%2Futilities</id>
	<title>Module:Lang/utilities - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.nordiclarp.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ALang%2Futilities"/>
	<link rel="alternate" type="text/html" href="https://www.nordiclarp.org/wiki/index.php?title=Module:Lang/utilities&amp;action=history"/>
	<updated>2026-04-27T10:47:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.nordiclarp.org/wiki/index.php?title=Module:Lang/utilities&amp;diff=2720&amp;oldid=prev</id>
		<title>Nordiclarpwikiadmin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.nordiclarp.org/wiki/index.php?title=Module:Lang/utilities&amp;diff=2720&amp;oldid=prev"/>
		<updated>2025-10-21T22:59:40Z</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&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 22:59, 21 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&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;!-- diff cache key nordic_larp_wiki:diff:1.41:old-2719:rev-2720 --&gt;
&lt;/table&gt;</summary>
		<author><name>Nordiclarpwikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.nordiclarp.org/wiki/index.php?title=Module:Lang/utilities&amp;diff=2719&amp;oldid=prev</id>
		<title>Nordic Larp Wiki&gt;Trappist the monk at 14:19, 9 January 2025</title>
		<link rel="alternate" type="text/html" href="https://www.nordiclarp.org/wiki/index.php?title=Module:Lang/utilities&amp;diff=2719&amp;oldid=prev"/>
		<updated>2025-01-09T14:19:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require(&amp;#039;strict&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local getArgs = require (&amp;#039;Module:Arguments&amp;#039;).getArgs;&lt;br /&gt;
local unicode = require (&amp;quot;Module:Unicode data&amp;quot;);								-- for is_latin()&lt;br /&gt;
local lang = require (&amp;#039;Module:Lang&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
local namespace = mw.title.getCurrentTitle().namespace;							-- used for categorization&lt;br /&gt;
&lt;br /&gt;
local err_texts = {																-- because wrapper templates have Latn/non-Latn text ordered according to the wrapper template&amp;#039;s name&lt;br /&gt;
	[&amp;#039;lang-sh-cyrl-latn&amp;#039;] = true,												-- this template has |1=cyrl script |2=latn script&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E R R O R _ M S G _ M A K E &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
assembles an error message from template name, message text, help link, and error category.&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;{{&amp;#039;, template, &amp;#039;}}&amp;lt;/span&amp;gt;&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function error_msg_make (msg, template, nocat)&lt;br /&gt;
	local out = {};&lt;br /&gt;
	local category = &amp;#039;Lang and lang-xx&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
	table.insert (out, table.concat ({&amp;#039;&amp;lt;span style=\&amp;quot;color:#d33\&amp;quot;&amp;gt;Error: &amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;{{&amp;#039;, template, &amp;#039;}}&amp;lt;/span&amp;gt;: &amp;#039;}));&lt;br /&gt;
	table.insert (out, msg);&lt;br /&gt;
	table.insert (out, table.concat ({&amp;#039; ([[Template:&amp;#039;, template, &amp;#039;#Error messages|help]])&amp;#039;}));&lt;br /&gt;
	table.insert (out, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;);&lt;br /&gt;
	&lt;br /&gt;
	if (0 == namespace or 10 == namespace) and not nocat then					-- categorize in article space (and template space to take care of broken usages)&lt;br /&gt;
		table.insert (out, table.concat ({&amp;#039;[[Category:Lang and lang-xx template errors]]&amp;#039;}));&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat (out);&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E P A R A T O R _ G E T &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
allowed separators are comma, semicolon, virgule, or a quoted string of text&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function separator_get (sep_param_val)&lt;br /&gt;
	if not sep_param_val then return &amp;#039;, &amp;#039; end;									-- not specified, use default&lt;br /&gt;
	if &amp;#039;,&amp;#039; == sep_param_val then return &amp;#039;, &amp;#039; end;&lt;br /&gt;
	if &amp;#039;;&amp;#039; == sep_param_val then return &amp;#039;; &amp;#039; end;&lt;br /&gt;
	if &amp;#039;/&amp;#039; == sep_param_val then return &amp;#039;/&amp;#039; end;&lt;br /&gt;
	local str;&lt;br /&gt;
	if sep_param_val:match (&amp;#039;^%b\&amp;quot;\&amp;quot;$&amp;#039;) then									-- if quoted string and uses double quotes&lt;br /&gt;
		str = sep_param_val:match (&amp;#039;%b\&amp;quot;\&amp;quot;&amp;#039;):gsub (&amp;#039;^&amp;quot;&amp;#039;, &amp;#039;&amp;#039;):gsub (&amp;#039;&amp;quot;$&amp;#039;, &amp;#039;&amp;#039;);&lt;br /&gt;
		return str;																-- return the contents of the quote&lt;br /&gt;
	elseif sep_param_val:match (&amp;#039;^%b\&amp;#039;\&amp;#039;$&amp;#039;) then								-- if quoted string and uses single quotes&lt;br /&gt;
		str = sep_param_val:match (&amp;#039;%b\&amp;#039;\&amp;#039;&amp;#039;):gsub (&amp;#039;^\&amp;#039;&amp;#039;, &amp;#039;&amp;#039;):gsub (&amp;#039;\&amp;#039;$&amp;#039;, &amp;#039;&amp;#039;);&lt;br /&gt;
		return str;																-- return the contents of the quote&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;, &amp;#039;;																-- default in case can&amp;#039;t extract quoted string&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; P A R A M _ S E L E C T &amp;gt;------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Selects the appropriate enumerated parameters for &amp;lt;text1&amp;gt; or &amp;lt;text2&amp;gt; according to &amp;lt;swap&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;args_t&amp;gt; - arguments table from frame&lt;br /&gt;
&amp;lt;lang_args_t&amp;gt; - arguments table to be supplied to _lang() (whichever text renders second)&lt;br /&gt;
&amp;lt;lang_xx_args_t&amp;gt; - arguments table to be supplied to _lang_xx_inherit() or _lang_xx_italic() (whichever text renders first)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function param_select (args_t, lang_args_t, lang_xx_args_t, swap)&lt;br /&gt;
	local enum_xx = swap and &amp;#039;2&amp;#039; or &amp;#039;1&amp;#039;;&lt;br /&gt;
	local enum = swap and &amp;#039;1&amp;#039; or &amp;#039;2&amp;#039;;&lt;br /&gt;
	&lt;br /&gt;
	lang_xx_args_t.script = args_t[&amp;#039;script&amp;#039; .. enum_xx];						-- these for &amp;lt;textn&amp;gt; that renders first (uses {{lang-xx}})&lt;br /&gt;
	lang_xx_args_t.region = args_t[&amp;#039;region&amp;#039; .. enum_xx];&lt;br /&gt;
	lang_xx_args_t.variant = args_t[&amp;#039;variant&amp;#039; .. enum_xx];&lt;br /&gt;
	lang_xx_args_t.italic = args_t[&amp;#039;italic&amp;#039; .. enum_xx];&lt;br /&gt;
	lang_xx_args_t.size = args_t[&amp;#039;size&amp;#039; .. enum_xx];&lt;br /&gt;
	&lt;br /&gt;
	lang_args_t.italic = args_t[&amp;#039;italic&amp;#039; .. enum];								-- these for &amp;lt;textn&amp;gt; that renders second (uses {{lang}})&lt;br /&gt;
	lang_args_t.size = args_t[&amp;#039;size&amp;#039; .. enum];&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I E T F _ T A G _ M A K E &amp;gt;----------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
make ietf tag for _lang() (second rendered &amp;lt;textn&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function ietf_tag_make (args_t, tag, swap)&lt;br /&gt;
	local ietf_tag_t = {tag};													-- initialize with &amp;lt;tag&amp;gt;&lt;br /&gt;
	local enum = swap and &amp;#039;1&amp;#039; or &amp;#039;2&amp;#039;;											-- when &amp;lt;swap&amp;gt; is true latin &amp;lt;text1&amp;gt; is rendered second by _lang()&lt;br /&gt;
	&lt;br /&gt;
	for _, param in ipairs ({&amp;#039;script&amp;#039;..enum, &amp;#039;region&amp;#039;..enum, &amp;#039;variant&amp;#039;..enum}) do&lt;br /&gt;
		if args_t[param] then table.insert (ietf_tag_t, args_t[param]) end		-- build &amp;lt;ietf_tag&amp;gt; from &amp;lt;enum&amp;gt;erated subtags&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat (ietf_tag_t, &amp;#039;-&amp;#039;);										-- concatenate subtags with hyphen separator and done&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; _ L A N G _ X 2 &amp;gt;--------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
mimics {{lang|&amp;lt;tag&amp;gt;|&amp;lt;text1&amp;gt;|&amp;lt;text2&amp;gt;}} except that &amp;lt;text2&amp;gt; is not a romanization of &amp;lt;text1&amp;gt; (which is always the&lt;br /&gt;
Latin-script form).  Intended for languages where two scripts are &amp;#039;official&amp;#039; or &amp;#039;native and equal in status&amp;#039; (sh&lt;br /&gt;
is and sr may be a candidate for this; are there others?)&lt;br /&gt;
&lt;br /&gt;
{{lang_x2|&amp;lt;tag&amp;gt;|&amp;lt;text1&amp;gt;|&amp;lt;text2&amp;gt;|swap=yes|script2=&amp;lt;script&amp;gt;|separator=[,|;|/|&amp;lt;quoted string&amp;gt;]}}&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;tag&amp;gt; - (required) language tag for both of &amp;lt;text1&amp;gt; and &amp;lt;text2&amp;gt;&lt;br /&gt;
	&amp;lt;text1&amp;gt; - (required) Latin-script text (always)&lt;br /&gt;
	&amp;lt;text2&amp;gt; - (required) non-Latin-script text (always)&lt;br /&gt;
	|swap= - when set to &amp;#039;yes&amp;#039;, swaps the rendered order so that &amp;lt;text2&amp;gt; renders first followed by &amp;lt;text1&amp;gt;; default is Latin-script &amp;lt;text1&amp;gt; first &lt;br /&gt;
	|separator = when single character ,;/ uses &amp;#039;, &amp;#039; (default), &amp;#039;; &amp;#039;, &amp;#039;/&amp;#039;; when quoted string (first and last characters must be matching single or double quotes) uses that string&lt;br /&gt;
&lt;br /&gt;
parameters supported by both of {{lang}} and {{lang-??}} templates are passed along:&lt;br /&gt;
	|cat=&lt;br /&gt;
	|nocat=&lt;br /&gt;
	&lt;br /&gt;
parameters supported only by {{lang-??}} that are not enumerated:&lt;br /&gt;
	|label=&lt;br /&gt;
	|link=&lt;br /&gt;
	&lt;br /&gt;
enumerated parameters:&lt;br /&gt;
	|script1= - ISO 15924 script tag for &amp;lt;text1&amp;gt;								-- when &amp;lt;text1&amp;gt; renders first, these are passed to _lang_xx_...() individually&lt;br /&gt;
	|region1= - ISO 3166 region tag for &amp;lt;text1&amp;gt;									-- when &amp;lt;text1&amp;gt; renders second, these are combined with &amp;lt;tag&amp;gt; to make an IETF tag for _lang()&lt;br /&gt;
	|variant1= - IETF tag for &amp;lt;text1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	|script2= - ISO 15924 script tag for &amp;lt;text2&amp;gt;								-- when &amp;lt;text2&amp;gt; renders first, these are passed to _lang_xx_...() individually&lt;br /&gt;
	|region2= - ISO 3166 region tag for &amp;lt;text2&amp;gt;									-- when &amp;lt;text2&amp;gt; renders second, these are combined with &amp;lt;tag&amp;gt; to make an IETF tag for _lang()&lt;br /&gt;
	|variant2= - IETF tag for &amp;lt;text2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	|italic1=&lt;br /&gt;
	|size1=&lt;br /&gt;
&lt;br /&gt;
	|italic2=&lt;br /&gt;
	|size2=&lt;br /&gt;
&lt;br /&gt;
this function calls:&lt;br /&gt;
	Module:Lang functions&lt;br /&gt;
		_lang_xx_inherit - when non-Latin &amp;lt;text2&amp;gt; renders first&lt;br /&gt;
		_lang_xx_italic - when Latin &amp;lt;text1&amp;gt; renders first&lt;br /&gt;
		_lang - to render &amp;lt;text2&amp;gt;&lt;br /&gt;
	Module:Unicode data function:&lt;br /&gt;
		is_Latin - error checking to make sure that &amp;lt;text1&amp;gt; is Latin-script text&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function _lang_x2 (args_t)&lt;br /&gt;
	local tag = args_t.tag or args_t[1];&lt;br /&gt;
	local text1 = args_t.text1 or args_t[2];&lt;br /&gt;
	local text2 = args_t.text2 or args_t[3];&lt;br /&gt;
	local translation = args_t.translation or args_t[4];&lt;br /&gt;
	local template_name = args_t.template_name or &amp;#039;lang-x2&amp;#039;;&lt;br /&gt;
	local nocat = (&amp;#039;yes&amp;#039; == args_t.nocat) or (&amp;#039;no&amp;#039; == args_t.cat);				-- boolean&lt;br /&gt;
&lt;br /&gt;
	if not (tag and text1 and text2) then&lt;br /&gt;
		return error_msg_make (&amp;#039;missing a required argument&amp;#039;, template_name, nocat);&lt;br /&gt;
	end&lt;br /&gt;
	if tag:find (&amp;#039;-&amp;#039;, 1, true) then&lt;br /&gt;
		return error_msg_make (&amp;#039;invalid language tag: &amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;&amp;#039; .. tag .. &amp;#039;&amp;lt;/span&amp;gt;; IETF format not supported&amp;#039;, template_name, nocat);&lt;br /&gt;
	end&lt;br /&gt;
	local is_latn, pos = unicode.is_Latin (text1);&lt;br /&gt;
	if not is_latn then&lt;br /&gt;
		return error_msg_make (&amp;#039;&amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;&amp;amp;lt;&amp;#039; .. ((err_texts[template_name:lower()] and &amp;#039;text2&amp;#039;) or &amp;#039;text1&amp;#039;) .. &amp;#039;&amp;gt;&amp;lt;/span&amp;gt; is not Latin script (pos &amp;#039; .. pos .. &amp;#039;)&amp;#039;, template_name, nocat);&lt;br /&gt;
	end&lt;br /&gt;
	is_latn, pos = unicode.is_Latin (text2);&lt;br /&gt;
	if is_latn then&lt;br /&gt;
		return error_msg_make (&amp;#039;&amp;lt;span style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;gt;&amp;amp;lt;&amp;#039; .. ((err_texts[template_name:lower()] and &amp;#039;text1&amp;#039;) or &amp;#039;text2&amp;#039;) .. &amp;#039;&amp;gt;&amp;lt;/span&amp;gt; is Latin script (pos &amp;#039; .. pos .. &amp;#039;)&amp;#039;, template_name, nocat);&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local swap = &amp;#039;yes&amp;#039; == args_t.swap;											-- boolean&lt;br /&gt;
	local out = {};&lt;br /&gt;
&lt;br /&gt;
	local ietf_tags = ietf_tag_make (args_t, tag, swap);						-- for calls to {{lang}}&lt;br /&gt;
																				-- create base-form arguments tables	&lt;br /&gt;
	local lang_xx_args_t = {[&amp;#039;code&amp;#039;]=tag, [&amp;#039;label&amp;#039;]=args_t.label, [&amp;#039;link&amp;#039;]=args_t.link, [&amp;#039;cat&amp;#039;]=args_t.cat, [&amp;#039;nocat&amp;#039;]=args_t.nocat, [&amp;#039;cat&amp;#039;]=args_t.cat};	-- for whichever &amp;lt;textn&amp;gt; renders first&lt;br /&gt;
	local lang_args_t = {[&amp;#039;code&amp;#039;]=ietf_tags, [&amp;#039;cat&amp;#039;]=args_t.cat, [&amp;#039;nocat&amp;#039;]=args_t.nocat, [&amp;#039;cat&amp;#039;]=args_t.cat};		-- for whichever &amp;lt;textn&amp;gt; renders second&lt;br /&gt;
	&lt;br /&gt;
	param_select (args_t, lang_args_t, lang_xx_args_t, swap);					-- load &amp;lt;lang_args_t&amp;gt;, &amp;lt;lang_xx_args_t&amp;gt; tables with appropriate enumerated parameters from &amp;lt;args_t&amp;gt; table according to &amp;lt;swap&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	if swap then																-- non-Latin script &amp;lt;text2&amp;gt; renders first&lt;br /&gt;
		lang_xx_args_t.text = text2;&lt;br /&gt;
		lang_args_t.text = text1;&lt;br /&gt;
		table.insert (out, lang._lang_xx_inherit (lang_xx_args_t));				-- render non-Latin script &amp;lt;text2&amp;gt; upright&lt;br /&gt;
	else																		-- Latin script &amp;lt;text1&amp;gt; renders first&lt;br /&gt;
		lang_xx_args_t.text = text1;&lt;br /&gt;
		lang_args_t.text = text2;&lt;br /&gt;
		table.insert (out, lang._lang_xx_italic (lang_xx_args_t));				-- render Latin script &amp;lt;text1&amp;gt; in italics&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	table.insert (out, separator_get (args_t.separator));						-- insert the separator&lt;br /&gt;
	table.insert (out, lang._lang (lang_args_t));								-- and render the other of &amp;lt;text1&amp;gt; or &amp;lt;text2&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	if translation then															-- if positional parameter 4 (translation of &amp;lt;text1&amp;gt; and &amp;lt;text2&amp;gt;)&lt;br /&gt;
		table.insert (out, lang._translation_make ({[&amp;#039;translation&amp;#039;] = translation, [&amp;#039;label&amp;#039;]=args_t.label, [&amp;#039;link&amp;#039;]=args_t.link}));	-- add translation to rendering&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat (out)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; L A N G _ X 2 &amp;gt;----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
implements {{lang-x2}}; template entry point&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function lang_x2 (frame)&lt;br /&gt;
	local args_t = getArgs (frame);&lt;br /&gt;
	return _lang_x2 (args_t);&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;
	lang_x2 = lang_x2,&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>Nordic Larp Wiki&gt;Trappist the monk</name></author>
	</entry>
</feed>