<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://academia.la/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages</id>
	<title>Module:languages - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://academia.la/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages"/>
	<link rel="alternate" type="text/html" href="https://academia.la/w/index.php?title=Module:languages&amp;action=history"/>
	<updated>2026-04-17T03:17:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://academia.la/w/index.php?title=Module:languages&amp;diff=1565&amp;oldid=prev</id>
		<title>Jācōbus at 03:18, 14 February 2023</title>
		<link rel="alternate" type="text/html" href="https://academia.la/w/index.php?title=Module:languages&amp;diff=1565&amp;oldid=prev"/>
		<updated>2023-02-14T03:18:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://academia.la/w/index.php?title=Module:languages&amp;amp;diff=1565&amp;amp;oldid=1487&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Jācōbus</name></author>
	</entry>
	<entry>
		<id>https://academia.la/w/index.php?title=Module:languages&amp;diff=1487&amp;oldid=prev</id>
		<title>Jācōbus: Created page with &quot;local export = {}  local function do_replacements(text, self, sc, replacement_data, function_name, recursed) 	-- If there are language-specific substitutes given in the data module, use those. 	if type(replacement_data) == &quot;table&quot; then 		-- If a script is specified, run this function with the script-specific data before continuing. 		local sc_code = sc:getCode() 		if replacement_data[sc_code] then 			text = do_replacements(text, self, sc, replacement_data[sc_code], funct...&quot;</title>
		<link rel="alternate" type="text/html" href="https://academia.la/w/index.php?title=Module:languages&amp;diff=1487&amp;oldid=prev"/>
		<updated>2023-02-07T22:44:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local function do_replacements(text, self, sc, replacement_data, function_name, recursed) 	-- If there are language-specific substitutes given in the data module, use those. 	if type(replacement_data) == &amp;quot;table&amp;quot; then 		-- If a script is specified, run this function with the script-specific data before continuing. 		local sc_code = sc:getCode() 		if replacement_data[sc_code] then 			text = do_replacements(text, self, sc, replacement_data[sc_code], funct...&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 function do_replacements(text, self, sc, replacement_data, function_name, recursed)&lt;br /&gt;
	-- If there are language-specific substitutes given in the data module, use those.&lt;br /&gt;
	if type(replacement_data) == &amp;quot;table&amp;quot; then&lt;br /&gt;
		-- If a script is specified, run this function with the script-specific data before continuing.&lt;br /&gt;
		local sc_code = sc:getCode()&lt;br /&gt;
		if replacement_data[sc_code] then&lt;br /&gt;
			text = do_replacements(text, self, sc, replacement_data[sc_code], function_name, true)&lt;br /&gt;
		-- Hant, Hans and Hani don't sort differently, so add a special case to avoid having to specify each one separately.&lt;br /&gt;
		elseif replacement_data.Han and (sc_code == &amp;quot;Hant&amp;quot; or sc_code == &amp;quot;Hans&amp;quot; or sc_code == &amp;quot;Hani&amp;quot;) then&lt;br /&gt;
			text = do_replacements(text, self, sc, replacement_data.Han, function_name, true)&lt;br /&gt;
		end&lt;br /&gt;
		-- Iterate over all strings in the &amp;quot;from&amp;quot; subtable, and gsub with the corresponding string in &amp;quot;to&amp;quot;. We work with the NFD decomposed forms, as this simplifies many replacements.&lt;br /&gt;
		if replacement_data.from then&lt;br /&gt;
			local gsub&lt;br /&gt;
			for i, from in ipairs(replacement_data.from) do&lt;br /&gt;
				-- We normalize each loop, to ensure multi-stage substitutions work correctly.&lt;br /&gt;
				text = sc:toFixedNFD(text)&lt;br /&gt;
				-- Check whether specific magic characters are present, as they rely on UTF-8 compatibility. If not, just use string.gsub. In most cases, doing this is faster than using mw.ustring.gsub every time.&lt;br /&gt;
				if from:match(&amp;quot;[%%.[%]*+%-?]&amp;quot;) then gsub = mw.ustring.gsub else gsub = string.gsub end&lt;br /&gt;
				text = gsub(text, sc:toFixedNFD(from), replacement_data.to[i] or &amp;quot;&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if replacement_data.remove_diacritics then&lt;br /&gt;
			text = sc:toFixedNFD(text)&lt;br /&gt;
			 -- Convert any specified exceptions into PUA characters, to avoid having diacritics stripped. Uses the supplemetary PUA planes (U+FXXXX &amp;amp; U+10XXXX), to ensure that any characters in the BMP (U+0XXXX) or SMP (U+1XXXX) can be round-trip converted to PUA.&lt;br /&gt;
			-- This will need to be reviewed if any characters in the SIP (U+2XXXX) or TIP (U+3XXXX) need to be processed by it, but as these planes are exclusively CJK characters as of 2022, this is unlikely to happen for the time being. However, it is unwise to start using non-PUA codepoints in the U+4XXXX-U+EXXXX range, as support for these is completely untested, so they may result in unpredictable behaviour.&lt;br /&gt;
			if replacement_data.remove_exceptions then&lt;br /&gt;
				local char, codepoint, len, substitute = mw.ustring.char, mw.ustring.codepoint, mw.ustring.len&lt;br /&gt;
				for _,exception in ipairs(replacement_data.remove_exceptions) do&lt;br /&gt;
					exception = sc:toFixedNFD(exception)&lt;br /&gt;
					substitute = {codepoint(exception, 1, len(exception))}&lt;br /&gt;
					for i, codepoint in ipairs(substitute) do substitute[i] = char(codepoint+0xF0000) end&lt;br /&gt;
					text = text:gsub(exception, table.concat(substitute))&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			-- Strip diacritics. This must use mw.ustring.gsub, to ensure the character class is UTF-8 compatible.&lt;br /&gt;
			text = mw.ustring.gsub(text, &amp;quot;[&amp;quot; .. replacement_data.remove_diacritics .. &amp;quot;]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
			-- Convert any exceptions back.&lt;br /&gt;
			if replacement_data.remove_exceptions then&lt;br /&gt;
				for _,exception in ipairs(replacement_data.remove_exceptions) do&lt;br /&gt;
					local char, codepoint, len, substitute = mw.ustring.char, mw.ustring.codepoint, mw.ustring.len&lt;br /&gt;
					exception = sc:toFixedNFD(exception)&lt;br /&gt;
					substitute = {codepoint(exception, 1, len(exception))}&lt;br /&gt;
					for i, codepoint in ipairs(substitute) do substitute[i] = char(codepoint+0xF0000) end&lt;br /&gt;
					text = text:gsub(table.concat(substitute), exception)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	elseif type(replacement_data) == &amp;quot;string&amp;quot; then&lt;br /&gt;
		-- If there is a dedicated function module, use that.&lt;br /&gt;
		local is_module, module = pcall(require, &amp;quot;Module:&amp;quot; .. replacement_data)&lt;br /&gt;
		if is_module then&lt;br /&gt;
			text = module[function_name](sc:toFixedNFD(text), self:getCode(), sc:getCode())&lt;br /&gt;
		-- If there is matching shared data, run this function again using that as the replacement data.&lt;br /&gt;
		else&lt;br /&gt;
			local m_shared = mw.loadData(&amp;quot;Module:languages/shareddata&amp;quot;)&lt;br /&gt;
			if m_shared[replacement_data] then&lt;br /&gt;
				return do_replacements(text, self, sc, m_shared[replacement_data], function_name, recursed)&lt;br /&gt;
			else&lt;br /&gt;
				error(&amp;quot;Replacement data does not match any shared data or an existing module.&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not recursed then&lt;br /&gt;
		-- Fix any discouraged sequences created during the substitution process, and normalize into the final form.&lt;br /&gt;
		text = sc:fixDiscouragedSequences(text)&lt;br /&gt;
		return sc:toFixedNFC(text)&lt;br /&gt;
	else&lt;br /&gt;
		return text&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local Language = {}&lt;br /&gt;
&lt;br /&gt;
function Language:getCode()&lt;br /&gt;
	return self._code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getCanonicalName()&lt;br /&gt;
	return self._rawData[1] or self._rawData.canonicalName&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getDisplayForm()&lt;br /&gt;
	return self:getCanonicalName()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getOtherNames(onlyOtherNames)&lt;br /&gt;
	self:loadInExtraData()&lt;br /&gt;
	return require(&amp;quot;Module:language-like&amp;quot;).getOtherNames(self, onlyOtherNames)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getAliases()&lt;br /&gt;
	self:loadInExtraData()&lt;br /&gt;
	return self._extraData.aliases or {}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getVarieties(flatten)&lt;br /&gt;
	self:loadInExtraData()&lt;br /&gt;
	return require(&amp;quot;Module:language-like&amp;quot;).getVarieties(self, flatten)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getType()&lt;br /&gt;
	return self._rawData.type or &amp;quot;regular&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getWikimediaLanguages()&lt;br /&gt;
	if not self._wikimediaLanguageObjects then&lt;br /&gt;
		local m_wikimedia_languages = require(&amp;quot;Module:wikimedia languages&amp;quot;)&lt;br /&gt;
		self._wikimediaLanguageObjects = {}&lt;br /&gt;
		local wikimedia_codes = self._rawData.wikimedia_codes or {self:getCode()}&lt;br /&gt;
		&lt;br /&gt;
		for _, wlangcode in ipairs(wikimedia_codes) do&lt;br /&gt;
			table.insert(self._wikimediaLanguageObjects, m_wikimedia_languages.getByCode(wlangcode))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._wikimediaLanguageObjects&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getWikipediaArticle()&lt;br /&gt;
	if self._rawData.wikipedia_article then&lt;br /&gt;
		return self._rawData.wikipedia_article &lt;br /&gt;
	elseif self._wikipedia_article then&lt;br /&gt;
		return self._wikipedia_article&lt;br /&gt;
	elseif self:getWikidataItem() and mw.wikibase then&lt;br /&gt;
		self._wikipedia_article = mw.wikibase.sitelink(self:getWikidataItem(), 'enwiki')&lt;br /&gt;
	end&lt;br /&gt;
	if not self._wikipedia_article then&lt;br /&gt;
		self._wikipedia_article = self:getCategoryName():gsub(&amp;quot;Creole language&amp;quot;, &amp;quot;Creole&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._wikipedia_article&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:makeWikipediaLink()&lt;br /&gt;
	return &amp;quot;[[w:&amp;quot; .. self:getWikipediaArticle() .. &amp;quot;|&amp;quot; .. self:getCanonicalName() .. &amp;quot;]]&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getWikidataItem()&lt;br /&gt;
	local item = self._rawData[2]&lt;br /&gt;
	&lt;br /&gt;
	if type(item) == &amp;quot;number&amp;quot; then&lt;br /&gt;
		return &amp;quot;Q&amp;quot; .. item&lt;br /&gt;
	else&lt;br /&gt;
		return item&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getScripts()&lt;br /&gt;
	if not self._scriptObjects then&lt;br /&gt;
		local m_scripts = require(&amp;quot;Module:scripts&amp;quot;)&lt;br /&gt;
		self._scriptObjects = {}&lt;br /&gt;
		&lt;br /&gt;
		for _, sc in ipairs(self:getScriptCodes()) do&lt;br /&gt;
			table.insert(self._scriptObjects, m_scripts.getByCode(sc))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._scriptObjects&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getScriptCodes()&lt;br /&gt;
	return self._rawData.scripts or self._rawData[4] or {&amp;quot;None&amp;quot;}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getFamily()&lt;br /&gt;
	if self._familyObject then&lt;br /&gt;
		return self._familyObject&lt;br /&gt;
	end&lt;br /&gt;
		&lt;br /&gt;
	local family = self._rawData[3] or self._rawData.family &lt;br /&gt;
	if family then&lt;br /&gt;
		self._familyObject = require(&amp;quot;Module:families&amp;quot;).getByCode(family)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._familyObject&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getAncestors()&lt;br /&gt;
	if not self._ancestorObjects then&lt;br /&gt;
		self._ancestorObjects = {}&lt;br /&gt;
		&lt;br /&gt;
		if self._rawData.ancestors then&lt;br /&gt;
			for _, ancestor in ipairs(self._rawData.ancestors) do&lt;br /&gt;
				table.insert(self._ancestorObjects, export.getByCode(ancestor) or require(&amp;quot;Module:etymology languages&amp;quot;).getByCode(ancestor))&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			local fam = self:getFamily()&lt;br /&gt;
			local protoLang = fam and fam:getProtoLanguage() or nil&lt;br /&gt;
			&lt;br /&gt;
			-- For the case where the current language is the proto-language&lt;br /&gt;
			-- of its family, we need to step up a level higher right from the start.&lt;br /&gt;
			if protoLang and protoLang:getCode() == self:getCode() then&lt;br /&gt;
				fam = fam:getFamily()&lt;br /&gt;
				protoLang = fam and fam:getProtoLanguage() or nil&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			while not protoLang and not (not fam or fam:getCode() == &amp;quot;qfa-not&amp;quot;) do&lt;br /&gt;
				fam = fam:getFamily()&lt;br /&gt;
				protoLang = fam and fam:getProtoLanguage() or nil&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			table.insert(self._ancestorObjects, protoLang)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._ancestorObjects&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function iterateOverAncestorTree(node, func)&lt;br /&gt;
	for _, ancestor in ipairs(node:getAncestors()) do&lt;br /&gt;
		if ancestor then&lt;br /&gt;
			local ret = func(ancestor) or iterateOverAncestorTree(ancestor, func)&lt;br /&gt;
			if ret then&lt;br /&gt;
				return ret&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getAncestorChain()&lt;br /&gt;
	if not self._ancestorChain then&lt;br /&gt;
		self._ancestorChain = {}&lt;br /&gt;
		local step = #self:getAncestors() == 1 and self:getAncestors()[1] or nil&lt;br /&gt;
		&lt;br /&gt;
		while step do&lt;br /&gt;
			table.insert(self._ancestorChain, 1, step)&lt;br /&gt;
			step = #step:getAncestors() == 1 and step:getAncestors()[1] or nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._ancestorChain&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:hasAncestor(otherlang)&lt;br /&gt;
	local function compare(ancestor)&lt;br /&gt;
		return ancestor:getCode() == otherlang:getCode()&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return iterateOverAncestorTree(self, compare) or false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getCategoryName(nocap)&lt;br /&gt;
	local name = self:getCanonicalName()&lt;br /&gt;
	&lt;br /&gt;
	-- If the name already has &amp;quot;language&amp;quot; in it, don't add it.&lt;br /&gt;
	if not name:find(&amp;quot;[Ll]anguage$&amp;quot;) then&lt;br /&gt;
		name = name .. &amp;quot; language&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if not nocap then&lt;br /&gt;
		name = mw.getContentLanguage():ucfirst(name)&lt;br /&gt;
	end&lt;br /&gt;
	return name&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:makeCategoryLink()&lt;br /&gt;
	return &amp;quot;[[:Category:&amp;quot; .. self:getCategoryName() .. &amp;quot;|&amp;quot; .. self:getDisplayForm() .. &amp;quot;]]&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:getStandardCharacters()&lt;br /&gt;
	return self._rawData.standardChars&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- If an initial colon is present and the text doesn't match an unsupported title beginning with a colon, remove it and return two values: the modified text and true. Otherwise, return text.&lt;br /&gt;
local function processEscape(text)&lt;br /&gt;
	local escaped&lt;br /&gt;
	if text and text:match(&amp;quot;^:&amp;quot;) and not mw.loadData(&amp;quot;Module:links/data&amp;quot;).unsupported_titles[text] then&lt;br /&gt;
		text = text:gsub(&amp;quot;^:&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		escaped = true&lt;br /&gt;
	end&lt;br /&gt;
	return text, not not escaped&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:makeEntryName(text, sc)&lt;br /&gt;
	if not sc or sc._type ~= &amp;quot;script object&amp;quot; then sc = require(&amp;quot;Module:scripts&amp;quot;).findBestScript(text, self) end&lt;br /&gt;
	-- Strip bold.&lt;br /&gt;
	text = text:gsub(&amp;quot;('*)'''(.-'*)'''&amp;quot;, &amp;quot;%1%2&amp;quot;)&lt;br /&gt;
	-- Strip soft hyphens.&lt;br /&gt;
	text = text:gsub(&amp;quot;­&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	-- Don't strip italics, as that would allow people to use it instead of {{m}} etc.&lt;br /&gt;
	local escaped; text, escaped = processEscape(text)&lt;br /&gt;
	-- Remove caret if it is used to capitalize parts of transliterations (unless this has been escaped).&lt;br /&gt;
	if not escaped and not sc:hasCapitalization() and sc:getCode() ~= &amp;quot;None&amp;quot; then text = text:gsub(&amp;quot;%^&amp;quot;, &amp;quot;&amp;quot;) end&lt;br /&gt;
	text = mw.text.unstrip(text)&lt;br /&gt;
	text = sc:fixDiscouragedSequences(text)&lt;br /&gt;
	text = sc:toFixedNFD(text)&lt;br /&gt;
	text = mw.ustring.match(text, &amp;quot;^[¿¡]?(.-[^%s%p].-)%s*[؟?!;՛՜ ՞ ՟？！︖︕।॥။၊་།]?$&amp;quot;) or text&lt;br /&gt;
	&lt;br /&gt;
	return do_replacements(text, self, sc, self._rawData.entry_name, &amp;quot;makeEntryName&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Return true if the language has display processing enabled, i.e. lang:makeDisplayText()&lt;br /&gt;
-- does non-trivial processing.&lt;br /&gt;
function Language:hasDisplayProcessing()&lt;br /&gt;
	return not not self._rawData.display_text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Apply display-text replacements to `text`, if any.&lt;br /&gt;
function Language:makeDisplayText(text, sc, keepCarets)&lt;br /&gt;
	if not sc or sc._type ~= &amp;quot;script object&amp;quot; then sc = require(&amp;quot;Module:scripts&amp;quot;).findBestScript(text, self) end&lt;br /&gt;
	local escaped; text, escaped = processEscape(text)&lt;br /&gt;
	-- Remove caret if it is used to capitalize parts of transliterations (unless this has been escaped).&lt;br /&gt;
	if not escaped and not keepCarets and not sc:hasCapitalization() and sc:getCode() ~= &amp;quot;None&amp;quot; then text = text:gsub(&amp;quot;%^&amp;quot;, &amp;quot;&amp;quot;) end&lt;br /&gt;
	-- Remove any interwiki link prefixes.&lt;br /&gt;
	if text:match(&amp;quot;:&amp;quot;) and not escaped then&lt;br /&gt;
		local prefix = text:match(&amp;quot;^([^:]+):&amp;quot;)&lt;br /&gt;
		local interwikis = mw.loadData(&amp;quot;Module:languages/shareddata&amp;quot;).interwikis&lt;br /&gt;
		if interwikis[prefix] then&lt;br /&gt;
			 -- Remove prefix plus colon.&lt;br /&gt;
			text = text:sub(#prefix + 2)&lt;br /&gt;
			-- If, additionally, there's a language code after the interwiki link, strip that too.&lt;br /&gt;
			local languageCode = text:match(&amp;quot;^([^:]+):&amp;quot;)&lt;br /&gt;
			if languageCode then&lt;br /&gt;
				text = text:sub(#languageCode + 2)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Temporarily convert strip markers to PUA characters to prevent them from being disrupted by the substitution process.&lt;br /&gt;
	local u, i, stripMarkers = mw.ustring.char, 1, {}&lt;br /&gt;
	for stripMarker in text:gmatch(&amp;quot;[.*]-&amp;quot; .. u(0x7F) .. &amp;quot;'\&amp;quot;`UNIQ%-%-%l+%-%x+%-QINU`\&amp;quot;'&amp;quot; .. u(0x7F)) do&lt;br /&gt;
		stripMarkers[i] = stripMarker&lt;br /&gt;
		text = text:gsub(stripMarker, u(0xE700+i), 1)&lt;br /&gt;
		i = i + 1&lt;br /&gt;
	end&lt;br /&gt;
	text = sc:fixDiscouragedSequences(text)&lt;br /&gt;
	text = sc:toFixedNFD(text)&lt;br /&gt;
	for j = 1, #stripMarkers do&lt;br /&gt;
		text = text:gsub(u(0xE700+j), stripMarkers[j])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Return whether the text was escaped, as this is used by the transliterate function.&lt;br /&gt;
	return do_replacements(text, self, sc, self._rawData.display_text, &amp;quot;makeDisplayText&amp;quot;), escaped&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:makeSortKey(text, sc)&lt;br /&gt;
	if not sc or sc._type ~= &amp;quot;script object&amp;quot; then sc = require(&amp;quot;Module:scripts&amp;quot;).findBestScript(text, self) end&lt;br /&gt;
	local escaped; text, escaped = processEscape(text)&lt;br /&gt;
	-- Remove caret if it is used to capitalize parts of transliterations (unless this has been escaped).&lt;br /&gt;
	if not escaped and not sc:hasCapitalization() and sc:getCode() ~= &amp;quot;None&amp;quot; then text = text:gsub(&amp;quot;%^&amp;quot;, &amp;quot;&amp;quot;) end&lt;br /&gt;
	local gsub = mw.ustring.gsub&lt;br /&gt;
	-- Remove initial hyphens and *.&lt;br /&gt;
	text = mw.text.unstrip(text)&lt;br /&gt;
	text = gsub(text, &amp;quot;^[-־ـ᠊*]+(.)&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	--Normalize.&lt;br /&gt;
	text = sc:fixDiscouragedSequences(text)&lt;br /&gt;
	text = sc:toFixedNFD(text)&lt;br /&gt;
	&lt;br /&gt;
	-- For languages with dotted dotless i, ensure that &amp;quot;İ&amp;quot; is sorted as &amp;quot;i&amp;quot;, and &amp;quot;I&amp;quot; is sorted as &amp;quot;ı&amp;quot;.&lt;br /&gt;
	if self._rawData.dotted_dotless_i then&lt;br /&gt;
		text = text:gsub(mw.ustring.toNFD(&amp;quot;İ&amp;quot;), &amp;quot;i&amp;quot;)&lt;br /&gt;
		text = sc:toFixedNFD(text:gsub(&amp;quot;I&amp;quot;, &amp;quot;ı&amp;quot;))&lt;br /&gt;
	end&lt;br /&gt;
	-- Convert to lowercase, make the sortkey, then convert to uppercase. Where the language has dotted dotless i, it is usually not necessary to convert &amp;quot;i&amp;quot; to &amp;quot;İ&amp;quot; and &amp;quot;ı&amp;quot; to &amp;quot;I&amp;quot; first, because &amp;quot;I&amp;quot; will always be interpreted as conventional &amp;quot;I&amp;quot; (not dotless &amp;quot;İ&amp;quot;) by any sorting algorithms, which will have been taken into account by the sortkey substitutions themselves. However, if no sortkey substitutions have been specified, then conversion is necessary so as to prevent &amp;quot;i&amp;quot; and &amp;quot;ı&amp;quot; both being sorted as &amp;quot;I&amp;quot;.&lt;br /&gt;
	text = mw.ustring.lower(text)&lt;br /&gt;
	text = do_replacements(text, self, sc, self._rawData.sort_key, &amp;quot;makeSortKey&amp;quot;)&lt;br /&gt;
	if self._rawData.dotted_dotless_i and not self._rawData.sort_key then&lt;br /&gt;
		text = text:gsub(&amp;quot;ı&amp;quot;, &amp;quot;I&amp;quot;)&lt;br /&gt;
		text = sc:toFixedNFC(text:gsub(&amp;quot;i&amp;quot;, &amp;quot;İ&amp;quot;))&lt;br /&gt;
	end&lt;br /&gt;
	text = mw.ustring.upper(text)&lt;br /&gt;
	&lt;br /&gt;
	-- Remove parentheses, as long as they are either preceded or followed by something.&lt;br /&gt;
	text = gsub(text, &amp;quot;(.)[()]+&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	text = gsub(text, &amp;quot;[()]+(.)&amp;quot;, &amp;quot;%1&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:overrideManualTranslit()&lt;br /&gt;
	return not not self._rawData.override_translit&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:transliterate(text, sc, module_override)&lt;br /&gt;
	if not ((module_override or self._rawData.translit_module) and text) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if module_override then&lt;br /&gt;
		require(&amp;quot;Module:debug&amp;quot;).track(&amp;quot;module_override&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Get the display form, and whether a colon-initial escape has been used.&lt;br /&gt;
	if not sc or sc._type ~= &amp;quot;script object&amp;quot; then sc = require(&amp;quot;Module:scripts&amp;quot;).findBestScript(text, self) end&lt;br /&gt;
	text = mw.text.unstrip(text)&lt;br /&gt;
	local escaped; text, escaped = self:makeDisplayText(text, sc, true)&lt;br /&gt;
	&lt;br /&gt;
	-- Transliterate.&lt;br /&gt;
	text = require(&amp;quot;Module:&amp;quot; .. (module_override or self._rawData.translit_module)).tr(text, self:getCode(), sc:getCode())&lt;br /&gt;
	&lt;br /&gt;
	-- If the text hasn't been escaped and the script does not use capitalization, then capitalize any letters of the transliteration which are immediately preceded by a caret, and then remove it. Otherwise, just return the text.&lt;br /&gt;
	if text and not escaped and text:match(&amp;quot;%^&amp;quot;) and not sc:hasCapitalization() and sc:getCode() ~= &amp;quot;None&amp;quot; then&lt;br /&gt;
		return mw.ustring.gsub(text, &amp;quot;(%^)(%l)&amp;quot;, function(a, b) return mw.ustring.upper(b) end)&lt;br /&gt;
	else&lt;br /&gt;
		return text&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:hasTranslit()&lt;br /&gt;
	return self._rawData.translit_module and true or false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:link_tr()&lt;br /&gt;
	return self._rawData.link_tr and true or false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:toJSON()&lt;br /&gt;
	local entryNamePatterns = nil&lt;br /&gt;
	local entryNameRemoveDiacritics = nil&lt;br /&gt;
	&lt;br /&gt;
	if self._rawData.entry_name then&lt;br /&gt;
		entryNameRemoveDiacritics = self._rawData.entry_name.remove_diacritics&lt;br /&gt;
		if self._rawData.entry_name.from then&lt;br /&gt;
			entryNamePatterns = {}&lt;br /&gt;
			for i, from in ipairs(self._rawData.entry_name.from) do&lt;br /&gt;
				table.insert(entryNamePatterns, {from = from, to = self._rawData.entry_name.to[i] or &amp;quot;&amp;quot;})&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local ret = {&lt;br /&gt;
		ancestors = self._rawData.ancestors,&lt;br /&gt;
		canonicalName = self:getCanonicalName(),&lt;br /&gt;
		categoryName = self:getCategoryName(&amp;quot;nocap&amp;quot;),&lt;br /&gt;
		code = self:getCode(),&lt;br /&gt;
		entryNamePatterns = entryNamePatterns,&lt;br /&gt;
		entryNameRemoveDiacritics = entryNameRemoveDiacritics,&lt;br /&gt;
		family = self._rawData[3] or self._rawData.family,&lt;br /&gt;
		otherNames = self:getOtherNames(true),&lt;br /&gt;
		aliases = self:getAliases(),&lt;br /&gt;
		varieties = self:getVarieties(),&lt;br /&gt;
		scripts = self._rawData.scripts or self._rawData[4],&lt;br /&gt;
		type = self:getType(),&lt;br /&gt;
		wikimediaLanguages = self._rawData.wikimedia_codes,&lt;br /&gt;
		wikidataItem = self:getWikidataItem(),&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return require(&amp;quot;Module:JSON&amp;quot;).toJSON(ret)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- Do NOT use these methods!&lt;br /&gt;
-- All uses should be pre-approved on the talk page!&lt;br /&gt;
function Language:getRawData()&lt;br /&gt;
	return self._rawData&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Language:getRawExtraData()&lt;br /&gt;
	self:loadInExtraData()&lt;br /&gt;
	return self._extraData&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Language.__index = Language&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getDataModuleName(code)&lt;br /&gt;
	if code:find(&amp;quot;^%l%l$&amp;quot;) then&lt;br /&gt;
		return &amp;quot;languages/data2&amp;quot;&lt;br /&gt;
	elseif code:find(&amp;quot;^%l%l%l$&amp;quot;) then&lt;br /&gt;
		local prefix = code:sub(1, 1)&lt;br /&gt;
		return &amp;quot;languages/data3/&amp;quot; .. prefix&lt;br /&gt;
	elseif code:find(&amp;quot;^[%l-]+$&amp;quot;) then&lt;br /&gt;
		return &amp;quot;languages/datax&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getExtraDataModuleName(code)&lt;br /&gt;
	if code:find(&amp;quot;^%l%l$&amp;quot;) then&lt;br /&gt;
		return &amp;quot;languages/extradata2&amp;quot;&lt;br /&gt;
	elseif code:find(&amp;quot;^%l%l%l$&amp;quot;) then&lt;br /&gt;
		local prefix = code:sub(1, 1)&lt;br /&gt;
		return &amp;quot;languages/extradata3/&amp;quot; .. prefix&lt;br /&gt;
	elseif code:find(&amp;quot;^[%l-]+$&amp;quot;) then&lt;br /&gt;
		return &amp;quot;languages/extradatax&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function getRawLanguageData(code)&lt;br /&gt;
	local modulename = export.getDataModuleName(code)&lt;br /&gt;
	return modulename and mw.loadData(&amp;quot;Module:&amp;quot; .. modulename)[code] or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function getRawExtraLanguageData(code)&lt;br /&gt;
	local modulename = export.getExtraDataModuleName(code)&lt;br /&gt;
	return modulename and mw.loadData(&amp;quot;Module:&amp;quot; .. modulename)[code] or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Language:loadInExtraData()&lt;br /&gt;
	if not self._extraData then&lt;br /&gt;
		-- load extra data from module and assign to _extraData field&lt;br /&gt;
		-- use empty table as a fallback if extra data is nil&lt;br /&gt;
		self._extraData = getRawExtraLanguageData(self:getCode()) or {}&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.makeObject(code, data)&lt;br /&gt;
	if data and data.deprecated then&lt;br /&gt;
		require(&amp;quot;Module:debug&amp;quot;).track {&lt;br /&gt;
			&amp;quot;languages/deprecated&amp;quot;,&lt;br /&gt;
			&amp;quot;languages/deprecated/&amp;quot; .. code&lt;br /&gt;
		}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return data and setmetatable({_rawData = data, _code = code, _type = &amp;quot;language object&amp;quot;}, Language) or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getByCode(code, paramForError, allowEtymLang, allowFamily)&lt;br /&gt;
	if type(code) ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
		error(&amp;quot;The function getByCode expects a string as its first argument, but received &amp;quot; .. (code == nil and &amp;quot;nil&amp;quot; or &amp;quot;a &amp;quot; .. type(code)) .. &amp;quot;.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local retval = export.makeObject(code, getRawLanguageData(code))&lt;br /&gt;
	if not retval and allowEtymLang then&lt;br /&gt;
		retval = require(&amp;quot;Module:etymology languages&amp;quot;).getByCode(code)&lt;br /&gt;
	end&lt;br /&gt;
	if not retval and allowFamily then&lt;br /&gt;
		retval = require(&amp;quot;Module:families&amp;quot;).getByCode(code)&lt;br /&gt;
	end&lt;br /&gt;
	if not retval and paramForError then&lt;br /&gt;
		require(&amp;quot;Module:languages/errorGetBy&amp;quot;).code(code, paramForError, allowEtymLang, allowFamily)&lt;br /&gt;
	end&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getByName(name, errorIfInvalid)&lt;br /&gt;
	local byName = mw.loadData(&amp;quot;Module:languages/by name&amp;quot;)&lt;br /&gt;
	local code = byName.all and byName.all[name] or byName[name]&lt;br /&gt;
	&lt;br /&gt;
	if not code then&lt;br /&gt;
		if errorIfInvalid then&lt;br /&gt;
			error(&amp;quot;The language name \&amp;quot;&amp;quot; .. name .. &amp;quot;\&amp;quot; is not valid. See [[Wiktionary:List of languages]].&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return export.makeObject(code, getRawLanguageData(code))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.getByCanonicalName(name, errorIfInvalid, allowEtymLang, allowFamily)&lt;br /&gt;
	local byName = mw.loadData(&amp;quot;Module:languages/canonical names&amp;quot;)&lt;br /&gt;
	local code = byName and byName[name]&lt;br /&gt;
&lt;br /&gt;
	local retval = code and export.makeObject(code, getRawLanguageData(code)) or nil&lt;br /&gt;
	if not retval and allowEtymLang then&lt;br /&gt;
		retval = require(&amp;quot;Module:etymology languages&amp;quot;).getByCanonicalName(name)&lt;br /&gt;
	end&lt;br /&gt;
	if not retval and allowFamily then&lt;br /&gt;
		local famname = name:match(&amp;quot;^(.*) languages$&amp;quot;)&lt;br /&gt;
		famname = famname or name&lt;br /&gt;
		retval = require(&amp;quot;Module:families&amp;quot;).getByCanonicalName(famname)&lt;br /&gt;
	end&lt;br /&gt;
	if not retval and errorIfInvalid then&lt;br /&gt;
		require(&amp;quot;Module:languages/errorGetBy&amp;quot;).canonicalName(name, allowEtymLang, allowFamily)&lt;br /&gt;
	end&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[	If language is an etymology language, iterates through parent languages&lt;br /&gt;
		until it finds a non-etymology language. ]]&lt;br /&gt;
function export.getNonEtymological(lang)&lt;br /&gt;
	while lang:getType() == &amp;quot;etymology language&amp;quot; do&lt;br /&gt;
		local parentCode = lang:getParentCode()&lt;br /&gt;
		lang = export.getByCode(parentCode)&lt;br /&gt;
			or require(&amp;quot;Module:etymology languages&amp;quot;).getByCode(parentCode)&lt;br /&gt;
			or require(&amp;quot;Module:families&amp;quot;).getByCode(parentCode)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return lang&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- for backwards compatibility only; modules should require the /error themselves&lt;br /&gt;
function export.err(lang_code, param, code_desc, template_tag, not_real_lang)&lt;br /&gt;
	return require(&amp;quot;Module:languages/error&amp;quot;)(lang_code, param, code_desc, template_tag, not_real_lang)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Jācōbus</name></author>
	</entry>
</feed>