<?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%3Awriting_systems</id>
	<title>Module:writing systems - 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%3Awriting_systems"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:writing_systems&amp;action=history"/>
	<updated>2026-04-16T11:13:26Z</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:writing_systems&amp;diff=423791&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  local en_utilities_module = &quot;Module:en-utilities&quot; local json_module = &quot;Module:JSON&quot; local language_like_module = &quot;Module:language-like&quot; local load_module = &quot;Module:load&quot; local table_module = &quot;Module:table&quot; local writing_systems_data_module = &quot;Module:writing systems/data&quot;  local gmatch = string.gmatch local make_object -- Defined below. local require = require local setmetatable = setmetatable local type = type  --[==[ Loaders for functions in other mod...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:writing_systems&amp;diff=423791&amp;oldid=prev"/>
		<updated>2025-01-11T13:06:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local en_utilities_module = &amp;quot;Module:en-utilities&amp;quot; local json_module = &amp;quot;Module:JSON&amp;quot; local language_like_module = &amp;quot;Module:language-like&amp;quot; local load_module = &amp;quot;Module:load&amp;quot; local table_module = &amp;quot;Module:table&amp;quot; local writing_systems_data_module = &amp;quot;Module:writing systems/data&amp;quot;  local gmatch = string.gmatch local make_object -- Defined below. local require = require local setmetatable = setmetatable local type = type  --[==[ Loaders for functions in other mod...&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 en_utilities_module = &amp;quot;Module:en-utilities&amp;quot;&lt;br /&gt;
local json_module = &amp;quot;Module:JSON&amp;quot;&lt;br /&gt;
local language_like_module = &amp;quot;Module:language-like&amp;quot;&lt;br /&gt;
local load_module = &amp;quot;Module:load&amp;quot;&lt;br /&gt;
local table_module = &amp;quot;Module:table&amp;quot;&lt;br /&gt;
local writing_systems_data_module = &amp;quot;Module:writing systems/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local gmatch = string.gmatch&lt;br /&gt;
local make_object -- Defined below.&lt;br /&gt;
local require = require&lt;br /&gt;
local setmetatable = setmetatable&lt;br /&gt;
local type = type&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==]&lt;br /&gt;
	local function deep_copy(...)&lt;br /&gt;
		deep_copy = require(table_module).deepCopy&lt;br /&gt;
		return deep_copy(...)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function keys_to_list(...)&lt;br /&gt;
		keys_to_list = require(table_module).keysToList&lt;br /&gt;
		return keys_to_list(...)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function load_data(...)&lt;br /&gt;
		load_data = require(load_module).load_data&lt;br /&gt;
		return load_data(...)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function pluralize(...)&lt;br /&gt;
		pluralize = require(en_utilities_module).pluralize&lt;br /&gt;
		return pluralize(...)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local function to_json(...)&lt;br /&gt;
		to_json = require(json_module).toJSON&lt;br /&gt;
		return to_json(...)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as &amp;quot;foo or get_foo()&amp;quot;, where the function get_foo sets the object to &amp;quot;foo&amp;quot; and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once &amp;quot;foo&amp;quot; has been set, &amp;quot;get_foo&amp;quot; will not be called again.]==]&lt;br /&gt;
	local writing_systems_data&lt;br /&gt;
	local function get_writing_systems_data()&lt;br /&gt;
		writing_systems_data, get_writing_systems_data = load_data(writing_systems_data_module), nil&lt;br /&gt;
		return writing_systems_data&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
local WritingSystem = {}&lt;br /&gt;
WritingSystem.__index = WritingSystem&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getCode()&lt;br /&gt;
	return self._code&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getCanonicalName()&lt;br /&gt;
	return self._data[1]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getDisplayForm(singular)&lt;br /&gt;
	return singular and (self._data.category or self:getCanonicalName()) or self:getCategoryName(&amp;quot;nocap&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getAliases()&lt;br /&gt;
	WritingSystem.getAliases = require(language_like_module).getAliases&lt;br /&gt;
	return self:getAliases()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getVarieties(flatten)&lt;br /&gt;
	WritingSystem.getVarieties = require(language_like_module).getVarieties&lt;br /&gt;
	return self:getVarieties(flatten)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getOtherNames()&lt;br /&gt;
	WritingSystem.getOtherNames = require(language_like_module).getOtherNames&lt;br /&gt;
	return self:getOtherNames()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getAllNames()&lt;br /&gt;
	WritingSystem.getAllNames = require(language_like_module).getAllNames&lt;br /&gt;
	return self:getAllNames()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[Returns a table of types as a lookup table (with the types as keys).&lt;br /&gt;
&lt;br /&gt;
Currently, the only possible type is {writing system}.]==]&lt;br /&gt;
function WritingSystem:getTypes()&lt;br /&gt;
	local types = self._types&lt;br /&gt;
	if types == nil then&lt;br /&gt;
		types = {[&amp;quot;writing system&amp;quot;] = true}&lt;br /&gt;
		local rawtypes = self._data.type&lt;br /&gt;
		if rawtypes then&lt;br /&gt;
			for t in gmatch(rawtypes, &amp;quot;[^,]+&amp;quot;) do&lt;br /&gt;
				types[t] = true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		self._types = types&lt;br /&gt;
	end&lt;br /&gt;
	return types&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[Given a list of types as strings, returns true if the writing system has all of them.]==]&lt;br /&gt;
function WritingSystem:hasType(...)&lt;br /&gt;
	WritingSystem.hasType = require(language_like_module).hasType&lt;br /&gt;
	return self:hasType(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getCategoryName(nocap)&lt;br /&gt;
	local name = pluralize(self._data.category or self:getCanonicalName())&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;
function WritingSystem: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;
--[==[Returns the Wikidata item id for the writing system or &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt;. This corresponds to the the second field in the data modules.]==]&lt;br /&gt;
function WritingSystem:getWikidataItem()&lt;br /&gt;
	WritingSystem.getWikidataItem = require(language_like_module).getWikidataItem&lt;br /&gt;
	return self:getWikidataItem()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getWikipediaArticle(noCategoryFallback, project)&lt;br /&gt;
	WritingSystem.getWikipediaArticle = require(language_like_module).getWikipediaArticle&lt;br /&gt;
	return self:getWikipediaArticle(noCategoryFallback, project)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[==[Returns the name of the Wikimedia Commons category page for the writing system.]==]&lt;br /&gt;
function WritingSystem:getCommonsCategory()&lt;br /&gt;
	WritingSystem.getCommonsCategory = require(language_like_module).getCommonsCategory&lt;br /&gt;
	return self:getCommonsCategory()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:getData()&lt;br /&gt;
	return self._data&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function WritingSystem:toJSON(opts)&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:getCode(),&lt;br /&gt;
		aliases = self:getAliases(),&lt;br /&gt;
		varieties = self:getVarieties(),&lt;br /&gt;
		otherNames = self:getOtherNames(),&lt;br /&gt;
		type = keys_to_list(self:getTypes()),&lt;br /&gt;
		wikidataItem = self:getWikidataItem(),&lt;br /&gt;
		wikipediaArticle = self:getWikipediaArticle(true),&lt;br /&gt;
	}&lt;br /&gt;
	-- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`.&lt;br /&gt;
	return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.makeObject(code, data)&lt;br /&gt;
	local data_type = type(data)&lt;br /&gt;
	if data_type ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
		error((&amp;quot;bad argument #2 to &amp;#039;makeObject&amp;#039; (table expected, got %s)&amp;quot;):format(data_type))&lt;br /&gt;
	end&lt;br /&gt;
	return setmetatable({_data = data, _code = code}, WritingSystem)&lt;br /&gt;
end&lt;br /&gt;
make_object = export.makeObject&lt;br /&gt;
&lt;br /&gt;
function export.getByCode(code)&lt;br /&gt;
	local data = (writing_systems_data or get_writing_systems_data())[code]&lt;br /&gt;
	return data ~= nil and make_object(code, data) or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
export.getByCanonicalName = export.getByCode&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>