Module:la-correlatives

From Wiktionary, the free dictionary
Jump to navigation Jump to search


local export = {}

local function make_edit_link(title)
	local URL = tostring(mw.uri.fullUrl(title, "action=edit"))
	return '<span class="plainlinks">[' .. URL .. ' edit]</span>'
end

-- Here, anything in template parameter notation, {{{thingy}}}, will be linked
-- with no transliteration, like {{l|la|thingy|tr=-}}.
local template =
[=[
<div class="NavFrame">
<div class="NavHead" align="left">[[Appendix:Latin correlatives|Latin correlatives]] <sup>(]=] .. make_edit_link("Module:la-correlatives") .. [=[)</sup></div>
<div class="NavContent" align="center">
{| class="wikitable"
!  rowspan="2" | type !! colspan="3" | demonstrative !! rowspan="2" | anaphoric !! rowspan="2" | identity !! rowspan="2" | interrogative/<br/>relative !! colspan="5" | indefinite !! rowspan="2" | negative !! rowspan="2" | other
|-
! proximal !! medial !! distal !! relative !! indefinite !! free choice !! universal !! negative polarity
|-
! basic
| {{{hic}}} || {{{iste}}}, {{{istic}}} || {{{ille}}}, {{{illic}}} || {{{is}}} ||  {{{ipse}}}, {{{īdem}}} || {{{quis}}}/{{{quī}}} || {{{quisquis}}}, {{{quīcumque}}} || {{{quis}}}, {{{quī}}}, {{{quīdam}}}, {{{aliquis}}}, {{{aliquī}}}, {{{quispiam}}} || {{{quīvis}}},  {{{quīlibet}}} || {{{quisque}}} || {{{quisquam}}}, {{{ūllus}}}, °{{{aliquisquam}}} || {{{nēmō}}}, {{{nihil}}}, {{{nūllus}}} || {{{alius}}}
|-
! dual
| || || || || || {{{uter}}} || {{{utercumque}}} || {{{alteruter}}} || {{{utervīs}}}, {{{uterlibet}}} || {{{uterque}}} || || {{{neuter}}} || {{{alter}}}
|-
! place
| {{{hīc}}} || {{{istīc}}} || {{{illīc}}} || {{{ibī̆}}} || {{{ibī̆dem}}} || {{{ubī̆}}} || {{{ubiubi}}}, {{{ubī̆cumque}}} || {{{alicubī}}}, {{{uspiam}}} || {{{ubivīs}}},  {{{ubilibet}}} ||  {{{ubīque}}} || {{{usquam}}} || {{{nusquam}}}, {{{nūllibī}}} || {{{alibī}}}, {{{aliās}}}
|-
! source
| {{{hinc}}} || {{{istinc}}} || {{{illinc}}} || {{{inde}}} || {{{indidem}}} || {{{unde}}} || {{{undecumque}}}, {{{undeunde}}} || {{{alicunde}}} || °{{{undelibet}}} || {{{undique}}} || || ||  {{{aliunde}}}
|-
! destination
| {{{hūc}}}, °{{{hōrsum}}} || {{{istūc}}}, °{{{istōrsum}}} ||  {{{illūc}}}, °{{{illōrsum}}} || {{{eō}}} || {{{eōdem}}} || {{{quō}}}, {{{quōrsum}}} || {{{quōquō}}}, {{{quōcumque}}} || {{{aliquō}}}, {{{quōpiam}}}, °{{{aliquōvorsum}}} || {{{quōvīs}}}, {{{quōlibet}}} || || {{{quōquam}}} || {{{nusquam}}}, {{{nūllōrsum}}} || {{{aliō}}}, {{{aliōrsum}}} 
|-
! method,<br>means,<br>path,<br>place
|  {{{hāc}}} || {{{istāc}}} ||  {{{illāc}}} || {{{eā}}} || {{{eādem}}} || {{{quā}}} || {{{quāquā}}}, {{{quācumque}}} || {{{aliquā}}} || {{{quāvīs}}}, {{{quālibet}}} || {{{quāque}}} || || {{{nēquāquam}}}, {{{haudquāquam}}} || {{{aliā}}}
|-
! manner
| {{{hōc}}} {{{modō}}} || {{{istō}}} {{{modō}}} || {{{illō}}} {{{modō}}} || {{{ita}}}, {{{sīc}}},<br/>{{{eō}}} {{{modō}}} || {{{item}}}, {{{itidem}}} || {{{ut}}}, {{{quī}}}, {{{quō}}} {{{modō}}}, {{{quōmodo}}}, {{{quemadmodum}}} || {{{utut}}}, {{{utcumque}}}, {{{quōmodocumque}}} || {{{quī}}}, {{{quōdam}}} {{{modō}}}, {{{aliquō}}} {{{modō}}} || {{{quōmodolibet}}} || {{{utīque}}} || {{{ūllō}}} {{{modō}}}  || {{{nūllō}}} {{{modō}}}  || {{{aliter}}}, {{{aliōquī}}}, {{{alterō}}}/{{{aliō}}} {{{modō}}}
|-
! time
| {{{num}}}, {{{nunc}}} || || {{{ōlim}}} || {{{tum}}}, {{{tunc}}} || {{{simul}}} || {{{quandō}}}, ‡{{{cum}}} || {{{cumque}}}, {{{quandōcumque}}}, {{{quandōque}}} || {{{quondam}}}, {{{aliquandō}}} || {{{quandōlibet}}} || {{{quandōque}}} || {{{umquam}}} || {{{numquam}}} || {{{aliās}}}
|-
! quantity
| || || ||  {{{tam}}} || †{{{tamen}}}, †{{{tandem}}} || {{{quam}}} || †{{{quamquam}}} || {{{aliquam}}} || {{{quamvīs}}}, {{{quamlibet}}} || || || ||
|-
! size
| || || || {{{tantus}}} || {{{tantusdem}}} || {{{quantus}}} || {{{quantuscumque}}} || {{{aliquantus}}} || {{{quantusvīs}}}, {{{quantuslibet}}} || || || ||
|-
! quality
| || || ||  {{{tālis}}} || ||  {{{quālis}}} || {{{quālis}}}, {{{quāliscumque}}} || {{{aliquālis}}} || {{{quālislibet}}} || || || ||
|-
! number
| || || ||  {{{tot}}} || {{{totidem}}} || {{{quot}}} || {{{quotquot}}}, {{{quotcumque}}} || {{{aliquot}}} ||  {{{quotlibet}}} || || || ||
|-
! order
| || || || {{{totus}}} || || {{{quotus}}} || {{{quotuscumque}}} || {{{aliquotus}}} || {{{quotuslibet}}} || || || ||
|-
! repetition
| || || || {{{totiēns}}} || || {{{quotiēns}}} || {{{quotiēnscumque}}} || {{{aliquotiēns}}} || {{{quotiēnslibet}}} || || || ||
|-
! multiplication
| || || || {{{totuplex}}} || ||  {{{quotuplex}}} || || || || || || ||
|-
| colspan="14" | † Turned conjunction with original meaning somewhat dissimulated<br/>° Rare<br/>‡only used as a conjunction, not as an interrogative
|}</div></div>]=]

function export.show(frame)
	if next(frame.args) then
		error("This module function does not require any parameters.")
	end
	
	local ugsub, decompose, U = mw.ustring.gsub, mw.ustring.toNFD, mw.ustring.char
	local macron = U(0x304)
	local breve = U(0x306)
	
	local function make_entry_name(text)
		text = ugsub(decompose(text), "[" .. macron .. breve .. "]", "")
		return text
	end
	
	local title = decompose(mw.title.getCurrentTitle().text)
	
	local function link_or_not(text)
		if text:find("[[", 1, true) then
			return text:gsub("%[%[([^%]]+)%]%]", link_or_not)
		else
			local entry_name = make_entry_name(text)
			if entry_name ~= title then
				return '[[' .. entry_name .. '#Latin|' .. text .. ']]'
			else
				return '<strong class="selflink">' .. text .. '</strong>'
			end
		end
	end
	
	local function tag(text)
		return '<span lang="la">' .. link_or_not(text) .. '</span>'
	end
	
	return (template:gsub('{{{([^}]+)}}}', tag))
end

return export