Module:User:kc kennylau/cats
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of kc kennylau, for his own experimentation. Items in this module may be added and removed at kc kennylau's discretion; do not rely on this module's stability.
local export = {}
local m_languages = require("Module:languages")
local m_families = require("Module:families")
--To call this function: {{subst:#invoke:User:kc_kennylau/cats|prefix_or_suffix}}
function export.prefix_or_suffix(frame)
pagename = mw.title.getCurrentTitle().text
pagename = mw.text.split(pagename,' ')
n = #pagename
result = '{{' .. pagename[n-2]:sub(1,#pagename[n-2]-2) .. 'cat'
result = result .. '|' .. m_languages.getByCanonicalName(table.concat(pagename,' ',1,n-4)):getCode()
result = result .. '|' .. mw.ustring.gsub(pagename[n],'[-־ـ]','')
if pagename[n-3] == "words" then
result = result .. '}}'
else
result = result .. '|pos=' .. mw.ustring.gsub(pagename[n-3],'s$','') .. '}}'
end
return result
end
--To call this function: {{subst:#invoke:User:kc_kennylau/cats|deriv}}
function export.deriv(frame)
pagename = mw.title.getCurrentTitle().text
pagename = mw.text.split(pagename,' terms derived from ')
from = m_languages.getByCanonicalName(pagename[1]):getCode()
to = m_languages.getByCanonicalName(pagename[2])
if to then to = to:getCode() else to = m_families.getFamilyByCanonicalName(mw.ustring.gsub(pagename[2],' languages$','')):getCode() end
result = '{{derivcatboiler|' .. from .. '|' ..to .. '}}'
return result
end
--To call this function: {{subst:#invoke:User:kc_kennylau/cats|sv_compound}}
function export.sv_compound(frame)
pagename = mw.ustring.gsub(mw.title.getCurrentTitle().text,'Swedish compounds with ','')
return '{{sv-compoundcat|' .. pagename .. '}}'
end
--To call this function: {{subst:#invoke:User:kc_kennylau/cats|topiccat}}
function export.topiccat(frame)
pagename = mw.title.getCurrentTitle().text
pagename = mw.text.split(pagename,':')
pagename = table.concat(pagename,'|')
return '{{topic cat|' .. pagename .. '}}'
end
return export