Module:CleTri

De MedFilm PPRD
Version datée du 25 mars 2025 à 12:53 par L.strappazon(AT)unistra.fr (discussion | contributions) (Page créée avec « local p = {} local dict = {"le","la","les","l","die","the"} function p.translate(pn) if dict[pn] then return dict[pn] end return pn end function p.fw(frame) local first_word = mw.text.split(frame.args[1], "[_ ']") return first_word -- return mw.text.split(frame.args[1], '[_ ]')[1] end function p.nom(frame) local tpn = mw.text.split(frame.args[1], '[_ ]') return(tpn[#tpn]) end function p.transl(frame) -- pn = string.gsub(frame.args[1], '^%s*(.-)%s*... »)
(diff) ← Version précédente | Version actuelle (diff) | Version suivante → (diff)

La documentation pour ce module peut être créée à Module:CleTri/doc

local p = {}

local dict = {"le","la","les","l","die","the"}

function p.translate(pn)
	if dict[pn] then
		return dict[pn]
	end
	return pn
end

function p.fw(frame)
	local first_word = mw.text.split(frame.args[1], "[_ ']")
	
	return first_word
--	return mw.text.split(frame.args[1], '[_ ]')[1]
end

function p.nom(frame)
	local tpn = mw.text.split(frame.args[1], '[_ ]')
	return(tpn[#tpn])
end

function p.transl(frame)
--	pn = string.gsub(frame.args[1], '^%s*(.-)%s*$', '%1')
	pn = frame.args[1]
	if dict[pn] then
		return '[[' .. pn .. '|' .. dict[pn] .. ']]'
	end
	return '[[' .. pn .. ']]'
end

function p.translNoLink(frame)
--	pn = string.gsub(frame.args[1], '^%s*(.-)%s*$', '%1')
	pn = frame.args[1]
	if dict[pn] then
		return dict[pn]
	end
	return pn
end
return p