Bước tới nội dung

Mô đun:ga-mutation

Từ điển mở Wiktionary
local m_links = require("Module:links")

local lang = require("Module:languages").getByCode("ga")

local export = {}


local function repl(forms, param)
	if param ~= "normal" and forms[param] == forms["normal"] then
		return "''không áp dụng''"
	end
	
	local ret = m_links.full_link({lang = lang, term = forms[param]})
	
	if param == "len" and forms.an ~= forms.normal then
		ret = ret .. "<br/>''after " .. m_links.full_link({lang = lang, alt = "an"}) .. ",'' " .. m_links.full_link({lang = lang, term = forms.an})
	end
	
	return ret
end


local table_cons = [=[
! gốc
! nhược hóa
! biến đổi<br/>phụ âm đầu
|-
| {{{normal}}}
| {{{len}}}
| {{{ecl}}}
]=]


local table_vowel = [=[
! gốc !! biến đổi<br/>phụ âm đầu !! thêm tiền tố h- !! thêm tiền tố t-
|-
| {{{normal}}}
| {{{ecl}}}
| {{{hpro}}}
| {{{tpro}}}
]=]


function export.mut(frame)
	local params = {
		[1] = {},
		}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local title = mw.title.getCurrentTitle().subpageText
	local forms = require("Module:ga-common").mutations(title, args[1])
	local wikicode = mw.ustring.find(mw.ustring.lower(title), "^[aeiouáéíóú]") and table_vowel or table_cons
	
	local result = frame:expandTemplate{ 
		title = 'inflection-table-top', 
		args = {
			title = '[[Phụ lục:Biến đổi âm trong tiếng Ireland|Biến đổi âm]] của ' .. require("Module:links").full_link({lang = lang, alt = title}, 'term'),
			palette = 'green'
		}
	}
	result = result .. '\n'
	result = result .. mw.ustring.gsub(wikicode, "{{{([a-z0-9_]+)}}}", function(param) return repl(forms, param) end)
	result = result .. frame:expandTemplate{ 
		title = 'inflection-table-bottom', 
		args = {
			notes = '<p style="font-size:85%;"><i>Lưu ý:</i> Một số dạng có thể chỉ là giả thuyết.<br/>Không phải dạng biến đổi nào cũng đều tồn tại.</p>'
		}
	}
	
	return result
end

return export