« Module:CleTri » : différence entre les versions

De MedFilm PPRD
L.strappazon(AT)unistra.fr (discussion | contributions)
Aucun résumé des modifications
L.strappazon(AT)unistra.fr (discussion | contributions)
Aucun résumé des modifications
 
(10 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
local p = {}
local p = {}


local dict = {"le","la","les","l","die","the"}
local articles = {"La","Le","Les","L","Die","The","Lo","la","le","les","l","die","the","lo"}
 
local l_articles ={}
function p.translate(pn)
for _,w in ipairs(articles) do
if dict[pn] then
l_articles[w] = true
return("Oui")
end
end
return pn
end
 
function p.fw(frame)
function p.fw(frame)
local first_word = mw.text.split(frame.args[1], "[_ ']")
local words = mw.text.split(frame.args[1], "[_ ']")
if l_articles[words[1]] then
return frame_args[1]
return string.sub(frame.args[1],#words[1]+2,-1)
-- return mw.text.split(frame.args[1], '[_ ]')[1]
else return frame.args[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
end
return '[[' .. pn .. ']]'
end
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
return p

Dernière version du 25 mars 2025 à 16:12

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

local p = {}

local articles = {"La","Le","Les","L","Die","The","Lo","la","le","les","l","die","the","lo"}
local l_articles ={}
	for _,w in ipairs(articles) do
		l_articles[w] = true
	end
	
function p.fw(frame)
	local words = mw.text.split(frame.args[1], "[_ ']")
	if l_articles[words[1]] then
		return string.sub(frame.args[1],#words[1]+2,-1)
	else return frame.args[1]
	end
end

return p