Module:Test

Définition, traduction, prononciation, anagramme et synonyme sur le dictionnaire libre Wiktionnaire.

La documentation pour ce module peut être créée à Module:Test/Documentation

local p = {}

function p.supprime_dernier_char(frame)
    chaine = frame.args[1]
    if chaine == nil then
        return ''
    end
    chaine_modifiee = mw.ustring.sub(chaine, 0, -2)
    return chaine_modifiee
end

function p.identifie_langue(frame)
	local gn = require('Module:langues').get_nom(frame.args[1])
	if gn then
		return frame.args[3] or gn
	end
	return frame.args[2] or ''
end

function p.formule_forme_adjective(frame)
	local gn = require('Module:langues').get_nom
	local lang = frame.args.lang or ""
	if gn(lang) == gn('de') or lang == gn('de') then
		local cas = frame.args.cas or frame.args[1]
		local genre = frame.args.genre or frame.args[2]
		local nombre = frame.args.nombre or frame.args[3]
		local decl = frame.args['déclinaison'] or frame.args[4]
		local t = {
			cas = {
				a = 'accusatif',
				d = 'datif',
				g = 'génitif',
				n = 'nominatif',
			},
			genre = {
				f = 'féminin',
				m = 'masculin',
				n = 'neutre',
			},
			nombre = {
				p = 'pluriel',
				s = 'singulier',
			},
			decl = {
				fa = 'de la déclinaison faible',
				fo = 'de la déclinaison forte',
				mi = 'de la déclinaison mixte',
			},
		}
		local s = ''
		if t.cas[cas] then
			s = s .. t.cas[cas] .. ' '
		end
		if t.genre[genre] then
			s = s .. t.genre[genre] .. ' '
		end
		if t.nombre[nombre] then
			s = s .. t.nombre[nombre] .. ' '
		end
		if t.decl[decl] then
			s = s .. t.decl[decl] .. ' '
		end
		if mw.ustring.len(s) > 1 then
			s = mw.ustring.sub(s, 1, -2)
			s = mw.ustring.upper(mw.ustring.sub(s, 1, 1)) .. mw.ustring.sub(s, 2, -1)
		end
		return s
	else
		return ''
	end
end

return p