<?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%3Aheadword-line_template_cat</id>
	<title>Module:headword-line template cat - 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%3Aheadword-line_template_cat"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:headword-line_template_cat&amp;action=history"/>
	<updated>2026-06-19T18:46:50Z</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:headword-line_template_cat&amp;diff=529733&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  local m_lang = require(&quot;Module:languages&quot;)  -- Allows us to get the language object for the longest language code -- in a template name. -- For instance, when given &quot;cel-bry-noun&quot;, where &quot;cel-bry&quot; yields -- Proto-Brythonic and &quot;cel&quot; yields Proto-Celtic, Proto-Brythonic wins out. local function get_from_hyphenated_prefix(title, getter)     local segments = {}     for segment in title:gmatch &quot;[^-]+&quot; do         table.insert(segments, segment)     end...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:headword-line_template_cat&amp;diff=529733&amp;oldid=prev"/>
		<updated>2026-06-14T11:32:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local m_lang = require(&amp;quot;Module:languages&amp;quot;)  -- Allows us to get the language object for the longest language code -- in a template name. -- For instance, when given &amp;quot;cel-bry-noun&amp;quot;, where &amp;quot;cel-bry&amp;quot; yields -- Proto-Brythonic and &amp;quot;cel&amp;quot; yields Proto-Celtic, Proto-Brythonic wins out. local function get_from_hyphenated_prefix(title, getter)     local segments = {}     for segment in title:gmatch &amp;quot;[^-]+&amp;quot; do         table.insert(segments, segment)     end...&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 m_lang = require(&amp;quot;Module:languages&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Allows us to get the language object for the longest language code&lt;br /&gt;
-- in a template name.&lt;br /&gt;
-- For instance, when given &amp;quot;cel-bry-noun&amp;quot;, where &amp;quot;cel-bry&amp;quot; yields&lt;br /&gt;
-- Proto-Brythonic and &amp;quot;cel&amp;quot; yields Proto-Celtic, Proto-Brythonic wins out.&lt;br /&gt;
local function get_from_hyphenated_prefix(title, getter)&lt;br /&gt;
    local segments = {}&lt;br /&gt;
    for segment in title:gmatch &amp;quot;[^-]+&amp;quot; do&lt;br /&gt;
        table.insert(segments, segment)&lt;br /&gt;
    end&lt;br /&gt;
    local object&lt;br /&gt;
    for i = #segments - 1, 1, -1 do&lt;br /&gt;
        local code = table.concat(segments, &amp;quot;-&amp;quot;, 1, i)&lt;br /&gt;
        object = getter(code)&lt;br /&gt;
        if object then&lt;br /&gt;
        	local rest = table.concat(segments, &amp;quot;-&amp;quot;, i + 1)&lt;br /&gt;
        	if rest == &amp;quot;&amp;quot; then rest = nil end&lt;br /&gt;
        	return object, rest&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.categorize(title, sortkey, explicit_langcode)&lt;br /&gt;
	local name = title.text&lt;br /&gt;
	local lang_obj, rest&lt;br /&gt;
	if explicit_langcode then&lt;br /&gt;
		lang_obj = m_lang.getByCode(explicit_langcode)&lt;br /&gt;
		-- Attempt to remove the lang code from the beginning of the template name.&lt;br /&gt;
		rest = name:gsub(&amp;quot;^&amp;quot; .. require(&amp;quot;Module:string utilities&amp;quot;).pattern_escape(explicit_langcode) .. &amp;quot;%-&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	else&lt;br /&gt;
		local rest&lt;br /&gt;
		lang_obj, rest = get_from_hyphenated_prefix(&lt;br /&gt;
			title.text,&lt;br /&gt;
			function(code)&lt;br /&gt;
				return m_lang.getByCode(code) or m_lang.getByCode(code .. &amp;quot;-pro&amp;quot;) or m_lang.getByCode(&amp;quot;inc-&amp;quot; .. code)&lt;br /&gt;
			end&lt;br /&gt;
			)&lt;br /&gt;
	end&lt;br /&gt;
	sortkey = sortkey or rest or name&lt;br /&gt;
	&lt;br /&gt;
	return &amp;quot;[[Category:&amp;quot; .. lang_obj:getCanonicalName()&lt;br /&gt;
		.. &amp;quot; headword-line templates|&amp;quot; .. sortkey .. &amp;quot;]]&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.main(frame)&lt;br /&gt;
	local current_title = mw.title.getCurrentTitle()&lt;br /&gt;
	if current_title.nsText == &amp;quot;&amp;quot; or current_title.nsText == &amp;quot;Reconstruction&amp;quot; then&lt;br /&gt;
		error(&amp;quot;This template is meant to be used in the Template namespace.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	-- The following makes it possible to do away with &amp;lt;includeonly&amp;gt;...&amp;lt;/includeonly&amp;gt; tags on documentation&lt;br /&gt;
	-- pages by ensuring we return nothing if expanded on a documentation page.&lt;br /&gt;
	if current_title.text:match(&amp;quot;/documentation$&amp;quot;) then return &amp;quot;&amp;quot; end&lt;br /&gt;
	&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	&lt;br /&gt;
	local title = current_title&lt;br /&gt;
	local is_demo = current_title.nsText == &amp;quot;Module&amp;quot;&lt;br /&gt;
		or (current_title.nsText == &amp;quot;Template&amp;quot;&lt;br /&gt;
		and current_title.baseText == &amp;quot;headword-line template cat&amp;quot;)&lt;br /&gt;
	if is_demo and args.title then&lt;br /&gt;
		title = mw.title.new(args.title)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local categories = export.categorize(title, args.sort, args[1])&lt;br /&gt;
	if is_demo then&lt;br /&gt;
		categories = mw.text.nowiki(categories)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return categories&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>