Module:Ressources/de

De Poképédia
Aller à la navigation Aller à la recherche

Permet d'automatiquement gérer l'élision de la préposition de / d'.


return function(str)
	local remove_accents = require("Module:Ressources/enleverAccents")
	local name = remove_accents(mw.text.split(mw.ustring.lower(str), " ")[1])
	-- Prend le premier "mot" du nom. Attention aux noms de Pokémon avec une espace (Mime Jr., M. Mime, etc),
	-- mais les formes composees du type "Hoopa Déchaîné" sont correctement gérées.
	
	local vowels = {"a", "e", "i", "o", "u", "y"}
	local de = {"hachecateur", "hariyama", "haydaim", "heatran", "hericendre", "ho-oh", "hoopa", "hoothoot", "hotte-de-fer", "hurle-queue", "ouistempo", "ouisticram", "yanma", "yanmega", "yuyu"}
	local d = {"hastacuda", "heledelle", "heliatronc", "helionceau", "herbizarre", "hexadron", "hexagel", "hippodocus", "hippopotas", "hydragla", "hydragon", "hypnomade", "hypocean", "hyporoi", "hypotrempe", "ymphect", "yveltal"}
	
	local i = 1
	
	while de[i] do
		if name == de[i]
		then return "de "
		end
		i = i + 1
	end
	
	i = 1
	while d[i] do
		if name == d[i]
		then return "d'"
		end
		i = i + 1
	end
	
	
	local first_letter = mw.ustring.sub(name, 1, 1)
	i = 1
	while vowels[i] do
		if first_letter == vowels[i]
		then return "d'"
		end
		i = i + 1
	end
	
	return "de "
end