<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://odden.us:443/thadar/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AScripts</id>
	<title>Module:Scripts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://odden.us:443/thadar/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AScripts"/>
	<link rel="alternate" type="text/html" href="https://odden.us:443/thadar/wiki/index.php?title=Module:Scripts&amp;action=history"/>
	<updated>2026-04-12T11:42:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://odden.us:443/thadar/wiki/index.php?title=Module:Scripts&amp;diff=1150&amp;oldid=prev</id>
		<title>Oa10712: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://odden.us:443/thadar/wiki/index.php?title=Module:Scripts&amp;diff=1150&amp;oldid=prev"/>
		<updated>2022-09-06T03:27:04Z</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 22:27, 5 September 2022&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>Oa10712</name></author>
	</entry>
	<entry>
		<id>https://odden.us:443/thadar/wiki/index.php?title=Module:Scripts&amp;diff=1149&amp;oldid=prev</id>
		<title>en&gt;Surjection: split less frequently used functions/code to their own submodules</title>
		<link rel="alternate" type="text/html" href="https://odden.us:443/thadar/wiki/index.php?title=Module:Scripts&amp;diff=1149&amp;oldid=prev"/>
		<updated>2022-01-26T13:51:34Z</updated>

		<summary type="html">&lt;p&gt;split less frequently used functions/code to their own submodules&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;
local Script = {}&lt;br /&gt;
&lt;br /&gt;
function Script:getCode()&lt;br /&gt;
	return self._code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getCanonicalName()&lt;br /&gt;
	return self._rawData.canonicalName&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getDisplayForm()&lt;br /&gt;
	return self:getCategoryName(&amp;quot;nocap&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getOtherNames(onlyOtherNames)&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;
function Script:getAliases()&lt;br /&gt;
	return self._rawData.aliases or {}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getVarieties(flatten)&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;
function Script:getParent()&lt;br /&gt;
	return self._rawData.parent&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getSystems()&lt;br /&gt;
	if not self._systemObjects then&lt;br /&gt;
		local m_systems = require(&amp;quot;Module:writing systems&amp;quot;)&lt;br /&gt;
		self._systemObjects = {}&lt;br /&gt;
		&lt;br /&gt;
		for _, sys in ipairs(self._rawData.systems or {}) do&lt;br /&gt;
			table.insert(self._systemObjects, m_systems.getByCode(sys))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self._systemObjects&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--function Script:getAllNames()&lt;br /&gt;
--	return self._rawData.names&lt;br /&gt;
--end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Script:getType()&lt;br /&gt;
	return &amp;quot;script&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Script:getCategoryName(nocap)&lt;br /&gt;
	local name = self._rawData.canonicalName&lt;br /&gt;
	&lt;br /&gt;
	-- If the name already has &amp;quot;code&amp;quot; or &amp;quot;semaphore&amp;quot; in it, don&amp;#039;t add it.&lt;br /&gt;
	-- No names contain &amp;quot;script&amp;quot;.&lt;br /&gt;
	if not name:find(&amp;quot;[Cc]ode$&amp;quot;) and not name:find(&amp;quot;[Ss]emaphore$&amp;quot;) then&lt;br /&gt;
		name = name .. &amp;quot; script&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 Script: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 Script:getWikipediaArticle()&lt;br /&gt;
	return self._rawData.wikipedia_article or self:getCategoryName()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Script:getCharacters()&lt;br /&gt;
	if self._rawData.characters then&lt;br /&gt;
		return self._rawData.characters&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 Script:countCharacters(text)&lt;br /&gt;
	if not self._rawData.characters then&lt;br /&gt;
		return 0&lt;br /&gt;
	else&lt;br /&gt;
		local _, num = mw.ustring.gsub(text, &amp;quot;[&amp;quot; .. self._rawData.characters .. &amp;quot;]&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
		return num&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Script:getDirection()&lt;br /&gt;
	local direction = self._rawData.direction&lt;br /&gt;
	if not direction then&lt;br /&gt;
		return nil&lt;br /&gt;
	else&lt;br /&gt;
		return direction&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Script:getRawData()&lt;br /&gt;
	return self._rawData&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Script:toJSON()&lt;br /&gt;
	local ret = {&lt;br /&gt;
		canonicalName = self:getCanonicalName(),&lt;br /&gt;
		categoryName = self:getCategoryName(&amp;quot;nocap&amp;quot;),&lt;br /&gt;
		code = self._code,&lt;br /&gt;
		otherNames = self:getOtherNames(true),&lt;br /&gt;
		aliases = self:getAliases(),&lt;br /&gt;
		varieties = self:getVarieties(),&lt;br /&gt;
		type = self:getType(),&lt;br /&gt;
		direction = self:getDirection(),&lt;br /&gt;
		characters = self:getCharacters(),&lt;br /&gt;
		parent = self:getParent(),&lt;br /&gt;
		systems = self._rawData.systems or {},&lt;br /&gt;
		wikipediaArticle = self._rawData.wikipedia_article,&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;
Script.__index = Script&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.makeObject(code, data)&lt;br /&gt;
	return data and setmetatable({ _rawData = data, _code = code }, Script) or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getByCode(code, paramForError, disallowNil)&lt;br /&gt;
	if code == nil and not disallowNil then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if code == &amp;quot;IPAchar&amp;quot; then&lt;br /&gt;
		require(&amp;quot;Module:debug/track&amp;quot;)(&amp;quot;IPAchar&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	local retval = export.makeObject(code, mw.loadData(&amp;quot;Module:scripts/data&amp;quot;)[code])&lt;br /&gt;
	if not retval and paramForError then&lt;br /&gt;
		require(&amp;quot;Module:languages&amp;quot;).err(code, paramForError, &amp;quot;script code&amp;quot;, nil, &amp;quot;not real lang&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return retval&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.getByCanonicalName(name)&lt;br /&gt;
	local code = mw.loadData(&amp;quot;Module:scripts/by name&amp;quot;)[name]&lt;br /&gt;
	&lt;br /&gt;
	if not code then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return export.makeObject(code, mw.loadData(&amp;quot;Module:scripts/data&amp;quot;)[code])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Find the best script to use, based on the characters of a string.&lt;br /&gt;
-- If forceDetect is set, run the detection algorithm even if there&amp;#039;s only one&lt;br /&gt;
-- possible script; in that case, if the text isn&amp;#039;t in the script, the return&lt;br /&gt;
-- value will be None.&lt;br /&gt;
function export.findBestScript(text, lang, forceDetect)&lt;br /&gt;
	if not text or not lang or not lang.getScripts then&lt;br /&gt;
		return export.getByCode(&amp;quot;None&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local scripts = lang:getScripts()&lt;br /&gt;
	&lt;br /&gt;
	if not scripts[2] and not forceDetect then&lt;br /&gt;
		return scripts[1]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return require(&amp;quot;Module:scripts/findBestScript&amp;quot;)(export, text, lang, scripts, forceDetect)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[&lt;br /&gt;
	Takes a codepoint or a character and finds the script code (if any) that is&lt;br /&gt;
	appropriate for it based on the codepoint, using the data module&lt;br /&gt;
	[[Module:scripts/recognition data]]. The data module was generated from the&lt;br /&gt;
	patterns in [[Module:scripts/data]] using [[Module:User:Erutuon/script recognition]].&lt;br /&gt;
&lt;br /&gt;
	Converts the character to a codepoint. Returns a script code if the codepoint&lt;br /&gt;
	is in the list of individual characters, or if it is in one of the defined&lt;br /&gt;
	ranges in the 4096-character block that it belongs to, else returns &amp;quot;None&amp;quot;.&lt;br /&gt;
]=]&lt;br /&gt;
function export.charToScript(char)&lt;br /&gt;
	return require(&amp;quot;Module:scripts/charToScript&amp;quot;).charToScript(char)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.findBestScriptWithoutLang(text)&lt;br /&gt;
	return require(&amp;quot;Module:scripts/charToScript&amp;quot;).findBestScriptWithoutLang(text)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>en&gt;Surjection</name></author>
	</entry>
</feed>