[go: up one dir, main page]
More Web Proxy on the site http://driver.im/跳转到内容

模組:Fr-conj

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


local export = {}
local m_links = require("Module:links")

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

-- defined below
local format_links, categorize

--entry point
function export.frconj(frame)
	--are we directly embedding through Template:fr-conj or calling the module? 
	local args = {}
	if frame.args["direct"] == "yes" then
		args = frame:getParent().args
	else
		args = frame.args
	end
	
	--create the forms
	local data = {forms = {}, categories = {}, en = false, y = false, yen = false, l = false, le = false, la = false, les = false, l_en = false, l_y = false, l_yen = false, lesen = false, lesy = false, lesyen = false, refl = false, reflen = false, refll = false, reflle = false, reflla = false, reflles = false, reflly = false, refllesy = false, refly = false, reflyen = false, aux = ""}
	data.aux = args["aux"]
	if not (data.aux == "avoir" or data.aux == "être") then
		data.aux = "avoir 或 être"
	end
	
	if (args["inf"] == nil or args["inf"] == "" or args["inf"] == mw.title.getCurrentTitle().text) then
		data.forms.inf_nolink = mw.title.getCurrentTitle().text
	else
		data.forms.inf_nolink = format_links(args["inf"])
	end
	data.forms.pp = format_links(args["pp"])
	data.forms.ppr = format_links(args["ppr"])
	if (args["pp"] == "—") then
		data.forms.pp_nolink = "—"
	elseif (args["pp"] == nil or mw.title.getCurrentTitle().text) then
		data.forms.pp_nolink = mw.title.getCurrentTitle().text
	else
		data.forms.pp_nolink = format_links(args["pp"])
	end
	if (args["ppr"] == "—") then
		data.forms.ppr_nolink = "—"
	elseif (args["ppr"] == nil or mw.title.getCurrentTitle().text) then
		data.forms.ppr_nolink = mw.title.getCurrentTitle().text
	else
		data.forms.ppr_nolink = format_links(args["ppr"])
	end
	
	local form_params = {
		"ind.p.1s", "ind.p.2s", "ind.p.3s", "ind.p.1p", "ind.p.2p", "ind.p.3p",
		"ind.i.1s", "ind.i.2s", "ind.i.3s", "ind.i.1p", "ind.i.2p", "ind.i.3p",
		"ind.ps.1s", "ind.ps.2s", "ind.ps.3s", "ind.ps.1p", "ind.ps.2p", "ind.ps.3p",
		"ind.f.1s", "ind.f.2s", "ind.f.3s", "ind.f.1p", "ind.f.2p", "ind.f.3p",
		"cond.p.1s", "cond.p.2s", "cond.p.3s", "cond.p.1p", "cond.p.2p", "cond.p.3p",
		"sub.p.1s", "sub.p.2s", "sub.p.3s", "sub.p.1p", "sub.p.2p", "sub.p.3p",
		"sub.pa.1s", "sub.pa.2s", "sub.pa.3s", "sub.pa.1p", "sub.pa.2p", "sub.pa.3p",
		"imp.p.2s", "imp.p.1p", "imp.p.2p",
	}
	
	for _, form in ipairs(form_params) do
		local key = form:gsub("%.", "_")
		data.forms[key] = format_links(args[form])
		local alt = form .. ".alt"
		local alt_arg = args[alt]
		if not (alt_arg == nil or alt_arg == "" or alt_arg == "—") then
			data.forms[key] = data.forms[key] .. " <i>or</i> " .. format_links(alt_arg)
		end
	end
	
	--a few ugly hacks
	data.forms.ger = args["ger.override"]
	data.forms.inf_comp = args["inf.override"]
	data.forms.ger_comp = args["ger.comp.override"]
	
	
	--finish up
	
	
	
	if mw.title.getCurrentTitle().nsText == "" then
		return export.make_table(data) .. categorize(args,data)
	else
		return export.make_table(data)
	end
end
	
function format_links(link)
	if (link == nil or link == "" or link == "—") then
		return "—"
	else
		return m_links.full_link({lang = lang, term = link})
	end
end


function categorize(args, data)
	output = ""
	if args.group == "1" or args.group == "1st" or args.group == "first" then
		output = output .. "[[Category:法語第一組動詞]]"
	elseif args.group == "2" or args.group == "2st" or args.group == "second" then
		output = output .. "[[Category:法語第二組動詞]]"
	elseif args.group == "3" or args.group == "3rd" or args.group == "third" then
		output = output .. "[[Category:法語第三組動詞]]"
	end
	if data.aux == "être" then
		output = output .. "[[Category:用être作為助動詞的法語動詞]"
	elseif data.aux == "avoir or être" then
		output = output .. "[[Category:用avoir或être作為助動詞的法語動詞]]"
	end
	return output
end

--split from Module:fr-verb/core
function export.make_table(data)
	local colors = {
		top = "#F0F0F0", gray = "#C0C0C0", straw = "#e2e4c0", blue = "#c0cfe4",
		gray_text = "#7f7f7f", green = "#c0e4c0",  tan = "#e4d4c0",
	}
	
	local aux_gerund = ""
	if data.aux == "avoir" then
		aux_gerund = "[[ayant]]"
	elseif data.aux == "[[s']][[être]]" then
		aux_gerund = "[[s']][[étant]]"
    elseif data.aux == "s'en être" then
		aux_gerund = "[[s']][[en]] [[étant]]"
    elseif data.aux == "s'y être" then
		aux_gerund = "[[s']][[y]] [[étant]]"
	elseif data.aux == "s'y en être" then
		aux_gerund = "[[s']][[y]] [[en]] [[étant]]"
	elseif data.aux == "se l'être" then
		aux_gerund = "[[se]] [[l']][[étant]]"
	elseif data.aux == "se les être" then
		aux_gerund = "[[se]] [[les]] [[étant]]"
	elseif data.aux == "l'en avoir" then
		aux_gerund = "[[l']][[en]] [[ayant]]"
	elseif data.aux == "l'y en avoir" then
		aux_gerund = "[[l']][[y]] [[en]] [[ayant]]"
	elseif data.aux == "les en avoir" then
		aux_gerund = "[[les]] [[en]] [[ayant]]"
	elseif data.aux == "les y en avoir" then
		aux_gerund = "[[les]] [[y]] [[en]] [[ayant]]"
	elseif data.aux == "se les y être" then
		aux_gerund = "[[se]] [[les]] [[y]] [[étant]]"
	elseif data.aux == "se l'y être" then
		aux_gerund = "[[se]] [[l']][[y]] [[étant]]"
	elseif data.aux == "l'avoir" then
		aux_gerund = "[[l]]'[[ayant]]"
	elseif data.aux == "l'être" then
		aux_gerund = "[[l]]'[[étant]]"
	elseif data.aux == "l'avoir 或 être" then
		aux_gerund = "[[l]]'[[ayant]] 或 [[étant]]"
	elseif data.aux == "l'y avoir" then
		aux_gerund = "[[l]]'[[y]] [[ayant]]"
	elseif data.aux == "l'y être" then
		aux_gerund = "[[l]]'[[y]] [[étant]]"
	elseif data.aux == "l'y avoir 或 être" then
		aux_gerund = "[[l]]'[[y]] [[ayant]] 或 [[étant]]"
	elseif data.aux == "les avoir" then
		aux_gerund = "[[les]] [[ayant]]"
	elseif data.aux == "les être" then
		aux_gerund = "[[les]] [[étant]]"
	elseif data.aux == "les avoir 或 être" then
		aux_gerund = "[[les]] [[ayant]] 或 [[étant]]"
	elseif data.aux == "les y avoir" then
		aux_gerund = "[[les]] [[y]] [[ayant]]"
	elseif data.aux == "les y être" then
		aux_gerund = "[[les]] [[y]] [[étant]]"
	elseif data.aux == "les y avoir 或 être" then
		aux_gerund = "[[les]] [[y]] [[ayant]] 或 [[étant]]"
    elseif data.aux == "y avoir" then
		aux_gerund = "[[y]] [[ayant]]"
    elseif data.aux == "y être" then
		aux_gerund = "[[y]] [[étant]]"
    elseif data.aux == "y avoir 或 être" then
		aux_gerund = "[[y]] [[ayant]] 或 [[étant]]"
    elseif data.aux == "y en avoir" then
		aux_gerund = "[[y]] [[en]] [[ayant]]"
    elseif data.aux == "y en être" then
		aux_gerund = "[[y]] [[en]] [[étant]]"
    elseif data.aux == "y en avoir 或 être" then
		aux_gerund = "[[y]] [[en]] [[ayant]] 或 [[étant]]"
    elseif data.aux == "en avoir" then
		aux_gerund = "[[en]] [[ayant]]"
    elseif data.aux == "en être" then
		aux_gerund = "[[en]] [[étant]]"
    elseif data.aux == "en avoir 或 être" then
		aux_gerund = "[[en] [[ayant]] 或 [[étant]]"
	elseif data.aux == "être" then
		aux_gerund = "[[étant]]"
	else
		aux_gerund = "[[ayant]] <i>or</i> [[étant]]"
	end
	
	local result = {}
	
	local inv = data.forms.pp_nolink
	local inv_sub = data.forms.pp_nolink
	local inversion_note = ""
	local inversion_sub_note = ""
	local replacement_note = "<sup>2</sup>"
	
	--Until someone implements a better solution
	
	if inv == "estimé" or inv == "opiné" or inv == "parlé" or inv == "pensé" or inv == "opiné" or inv == "trouvé" or inv == "pu" then
		inversion_note = "<sup>2</sup>"
		inversion_sub_note = "<sup>2</sup>"
		replacement_note = "<sup>3</sup>"
		if inv == "pu" then
			inv = "puis"
			inv_sub = "puissé"
			inversion_sub_note = "<sup>3</sup>"
			replacement_note = "<sup>4</sup>"
		end
	end
	
	-- Template parameter syntax refers to the corresponding item in the
	-- data.forms or colors table:
	-- {{{inf_nolink}}} -> data.forms.inf_nolink
	-- {{{green}}}		-> colors.green
	if data.notes then table.insert(result, data.notes .. '\n') end
	table.insert(result,
[=[
<div class="NavFrame" style="clear:both">
<div class="NavHead" align=left><span class="Latn lang-fr" lang="fr">''{{{inf_nolink}}}''</span> 的变位 <span style="font-size:90%;">(参见[[Appendix:法语动词]])</span></div>
<div class="NavContent" align=center>
{| style="background:{{{top}}};width:100%;border-collapse:separate;border-spacing:2px" class="inflection-table"
|-
! colspan="1" rowspan="2" style="background:{{{straw}}}" | <span title="infinitif">不定式</span>
! colspan="1" style="height:3em;background:{{{straw}}}" | <small>简单</small>
| <span class="Latn lang-fr" lang="fr">{{{inf_nolink}}}</span>
|-
! colspan="1" style="height:3em;background:{{{straw}}}" | <small>复合</small>
]=])
	if data.forms.inf_comp == "" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | ' ..data.forms.inf_comp.. ' \n')
	elseif data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i> + 过去分词\n')
	end
	table.insert(result,
[=[
|-
! colspan="1" rowspan="2" style="background:{{{straw}}}" | <span title="participe présent">现在分词</span> 或 <span title="">动名词</span><sup>1</sup>
! colspan="1" style="height:3em;background:{{{straw}}}" | <small>简单</small>
| {{{ppr}}}
|-
! colspan="1" style="height:3em;background:{{{straw}}}" | <small>复合</small>
]=])
	if data.forms.ger_comp == "" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | ' ..data.forms.ger_comp.. '\n')
	elseif data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>' .. aux_gerund .. '</i> + 过去分词 \n')
	end
	table.insert(result,
[=[
|-
! colspan="2" style="background:{{{straw}}}" | <span title="participe passé">过去分词</span>
| {{{pp}}}
|-
! colspan="2" rowspan="2" |
! colspan="3" style="background:{{{gray}}}" | 单数
! colspan="3" style="background:{{{gray}}}" | 复数
|-
! style="background:{{{gray}}};width:12.5%" | 第一人称
! style="background:{{{gray}}};width:12.5%" | 第二人称
! style="background:{{{gray}}};width:12.5%" | 第三人称
! style="background:{{{gray}}};width:12.5%" | 第一人称
! style="background:{{{gray}}};width:12.5%" | 第二人称
! style="background:{{{gray}}};width:12.5%" | 第三人称
|-
! style="background:{{{blue}}}" colspan="2" | <span title="indicatif">直陈式</span>
! style="background:{{{blue}}}" | je (j’)
! style="background:{{{blue}}}" | tu
! style="background:{{{blue}}}" | il, elle
! style="background:{{{blue}}}" | nous
! style="background:{{{blue}}}" | vous
! style="background:{{{blue}}}" | ils, elles
|-
! rowspan="5" style="background:{{{blue}}}" | <small>(简单)</small>
! style="height:3em;background:{{{blue}}}" | <span title="présent">现在时</span>
| {{{ind_p_1s}}}
| {{{ind_p_2s}}}
| {{{ind_p_3s}}}
| {{{ind_p_1p}}}
| {{{ind_p_2p}}}
| {{{ind_p_3p}}}
|-
! style="height:3em;background:{{{blue}}}" | <span title="imparfait">未完成过去时</span>
| {{{ind_i_1s}}}
| {{{ind_i_2s}}}
| {{{ind_i_3s}}}
| {{{ind_i_1p}}}
| {{{ind_i_2p}}}
| {{{ind_i_3p}}}
|-
! style="height:3em;background:{{{blue}}}" | <span title="passé simple">过去时</span><sup>2</sup>
| {{{ind_ps_1s}}}
| {{{ind_ps_2s}}}
| {{{ind_ps_3s}}}
| {{{ind_ps_1p}}}
| {{{ind_ps_2p}}}
| {{{ind_ps_3p}}}
|-
! style="height:3em;background:{{{blue}}}" | <span title="futur simple">将来时</span>
| {{{ind_f_1s}}}
| {{{ind_f_2s}}}
| {{{ind_f_3s}}}
| {{{ind_f_1p}}}
| {{{ind_f_2p}}}
| {{{ind_f_3p}}}
|-
! style="height:3em;background:{{{blue}}}" | <span title="conditionnel présent">条件式现在时</span>
| {{{cond_p_1s}}}
| {{{cond_p_2s}}}
| {{{cond_p_3s}}}
| {{{cond_p_1p}}}
| {{{cond_p_2p}}}
| {{{cond_p_3p}}}
|-
! rowspan="5" style="background:{{{blue}}}" | <small>(复合)</small>
! style="height:3em;background:{{{blue}}}" | <span title="passé composé">过去时</span>
]=])
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的现在直陈式 + 过去分词\n')
	end
	table.insert(result, '|-\n! style="height:3em;background:{{{blue}}}" | <span title="plus-que-parfait">愈过去时</span>\n')
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的未完成过去直陈式 + 过去分词\n')
	end
	table.insert(result, '|-\n! style="height:3em;background:{{{blue}}}" | <span title="passé antérieur">先过去时</span><sup>2</sup>\n')
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的简单过去时 + 过去分词\n')
	end
	table.insert(result, '|-\n! style="height:3em;background:{{{blue}}}" | <span title="futur antérieur">先将来时</span>\n')
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的将来时 + 过去分词\n')
	end
	table.insert(result, '|-\n! style="height:3em;background:{{{blue}}}" | <span title="conditionnel passé">条件式过去时</span>\n')
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的条件式 + 过去分词\n')
	end
	table.insert(result,
[=[
|-
! style="background:{{{green}}}" colspan="2" | <span title="subjonctif">虚拟式</span>
! style="background:{{{green}}}" | que je (j’)
! style="background:{{{green}}}" | que tu
! style="background:{{{green}}}" | qu’il, qu’elle
! style="background:{{{green}}}" | que nous
! style="background:{{{green}}}" | que vous
! style="background:{{{green}}}" | qu’ils, qu’elles
|-
! rowspan="2" style="background:{{{green}}}" | <small>(简单)</small>
! style="height:3em;background:{{{green}}}" | <span title="subjonctif présent">现在时</span>
| {{{sub_p_1s}}}
| {{{sub_p_2s}}}
| {{{sub_p_3s}}}
| {{{sub_p_1p}}}
| {{{sub_p_2p}}}
| {{{sub_p_3p}}}
|-
! style="height:3em;background:{{{green}}}" rowspan="1" | <span title="subjonctif imparfait">未完成过去时</span><sup>2</sup>
| {{{sub_pa_1s}}}
| {{{sub_pa_2s}}}
| {{{sub_pa_3s}}}
| {{{sub_pa_1p}}}
| {{{sub_pa_2p}}}
| {{{sub_pa_3p}}}
|-
! rowspan="2" style="background:{{{green}}}" | <small>(复合)</small>
! style="height:3em;background:{{{green}}}" | <span title="subjonctif passé">过去时</span>
]=])
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的现在虚拟式 + 过去分词\n')
	end
	table.insert(result, '|-\n! style="height:3em;background:{{{green}}}" | <span title="subjonctif plus-que-parfait">过去完成时</span><sup>2</sup>\n')
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! colspan="6" style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的未完成过去虚拟式 + 过去分词\n')
	end
	table.insert(result,
[=[
|-
! colspan="2" style="background:{{{tan}}}" | <span title="impératif">命令式</span>
! style="background:{{{tan}}}" | –
! style="background:{{{tan}}}" | <s>tu</s>
! style="background:{{{tan}}}" | –
! style="background:{{{tan}}}" | <s>nous</s>
! style="background:{{{tan}}}" | <s>vous</s>
! style="background:{{{tan}}}" | –
|-
! style="height:3em;background:{{{tan}}}" colspan="2" | <span title="">简单</span>
| —
| {{{imp_p_2s}}}
| —
| {{{imp_p_1p}}}
| {{{imp_p_2p}}}
| —
|-
! style="height:3em;background:{{{tan}}}" colspan="2" | <span title="">复合</span>
| —
]=])
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的简单命令式 + 过去分词\n')
	end
	table.insert(result,
[=[
| —
]=])
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的简单命令式 + 过去分词\n')
	end
	table.insert(result,
[=[
]=])
	if data.forms.pp_nolink == "—" then
		table.insert(result, '! style="background:#DEDEDE" | — \n')
	else
		table.insert(result, '! style="background:#DEDEDE" | <i>[[' .. data.aux .. ']]</i>的简单命令式 + 过去分词\n')
	end
	table.insert(result,
[=[
| —
|-
| colspan="8" |<sup>1</sup> 法语中的动名词只能搭配介词<i>[[en]]</i>使用。
|-
]=])
if inversion_note ~= "" then
	table.insert(result,
[=[
| colspan="8" |<sup>2</sup> 倒裝時使用 <i>[[]=] .. inv .. [=[]]</i>。
|-
]=])
end
if inv ~= inv_sub then
	table.insert(result,
[=[
| colspan="8" |<sup>3</sup> 倒裝時使用 <i>[[]=] .. inv_sub .. [=[]]</i>。
|-
]=])
end
table.insert(result,
[=[
| colspan="8" |]=] .. replacement_note .. [=[ 在不那麼正式的寫作或口語中,簡單過去時、先過去時、未完成虛擬式、過去完成時虛擬式時態可能會分別被直陳式現在完成時、直陳式過去完成時、虛擬式現在時和虛擬式過去時時態所替代 (Christopher Kendris [1995], <i>Master the Basics: French</i>, pp. [https://books.google.fr/books?id=g4G4jg5GWMwC&pg=PA77 77], [https://books.google.fr/books?id=g4G4jg5GWMwC&pg=PA78 78], [https://books.google.fr/books?id=g4G4jg5GWMwC&pg=PA79 79], [https://books.google.fr/books?id=g4G4jg5GWMwC&pg=PA81 81])。
|}
</div>
</div>
]=])
	
	--[[
	setmetatable(data.forms, { __index =
		function(t, k)
			mw.log('No key for ' .. k)
		end
	})
	--]]
	
	return string.gsub(table.concat(result), "{{{([^}]+)}}}",
		function(code)
			return data.forms[code] or colors[code]
		end)
end

return export