模組:Grc-pronoun table

維基詞典,自由的多語言詞典


local export = {}

local U = mw.ustring.char
local macron = U(0x304)
local breve = U(0x306)

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

local pronoun_table_templates = {
	[1] = -- {{Ancient Greek personal pronouns 1}}
[=[{| class="wikitable" style="font-size: smaller; float: right;"
|+ [[第一人稱]]代詞 <sup>(]=] .. make_edit_link("Module:grc-pronoun table") .. [=[)</sup>
! rowspan="2" | 格 !! colspan="2" | [[單數]] !! [[雙數]] !! [[複數]]
|-
! 重讀 !! 非重讀 !! 重讀  !! 重讀 
|-
! [[主格]]
| {{{ἐγώ}}} || || {{{νώ}}}, {{{νῶϊ}}} || {{{ἡμεῖς}}}
|-
! [[屬格]]
| {{{ἐμοῦ}}} || {{{μου}}} || {{{νῷν}}} || {{{ἡμῶν}}}
|-
! [[與格]]
| {{{ἐμοί}}} || {{{μοι}}} || {{{νῷν}}} || {{{ἡμῖν}}}
|-
! [[賓格]]
| {{{ἐμέ}}} || {{{με}}} || {{{νώ}}}, {{{νῶϊ}}} || {{{ἡμᾶς}}}
|-
! colspan="5" |
|-
! 形容詞
| {{{ἐμός}}} || || || {{{ἡμέτερος}}}
|}]=],
	[2] = -- {{Ancient Greek personal pronouns 2}}
[=[{| class="wikitable" style="font-size: smaller; float: right;"
|+ [[第二人稱]]代詞 <sup>(]=] .. make_edit_link("Module:grc-pronoun table") .. [=[)</sup>
! rowspan="2" | 格 !! colspan="2" | [[單數]] !! [[雙數]] !! [[複數]]
|-
! 重讀 !! 非重讀 !! 重讀  !! 重讀
|-
! [[主格]]
| {{{σύ}}} || || {{{σφώ}}}, {{{σφῶϊ}}} || {{{ῡ̔μεῖς}}}
|-
! [[屬格]]
| {{{σοῦ}}} || {{{σου}}} || {{{σφῷν}}} || {{{ῡ̔μῶν}}}
|-
! [[與格]]
| {{{σοί}}} || {{{σοι}}} || {{{σφῷν}}} || {{{ῡ̔μῖν}}}
|-
! [[賓格]]
| {{{σέ}}} || {{{σε}}} || {{{σφώ}}}, {{{σφῶϊ}}} || {{{ῡ̔μᾶς}}}
|-
! colspan="5" |
|-
! 形容詞
| {{{σός}}} || || || {{{ῡ̔μέτερος}}}
|}]=],
}

function export.pronoun_table(frame)
	local person = tonumber(frame.args[1])
	if not person then
		error('Parameter 1 should be a number.')
	end
	local template = pronoun_table_templates[person]
		or error('No template for person ' .. person .. '.')
	
	local ugsub, decompose = mw.ustring.gsub, mw.ustring.toNFD
	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(term)
		local entry_name = make_entry_name(term)
		if entry_name ~= title then
			return '<span class="polytonic" lang="grc">[[' .. entry_name .. '#古希臘語|' .. term .. ']]</span>'
		else
			return '<strong class="selflink polytonic" lang="grc">' .. term .. '</strong>'
		end
	end
	
	return (template:gsub('{{{([^}]+)}}}', link))
end

return export