Chronos chronos left.png
Rusmed logo color.png
Chronos chronos right.png

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Module:Translate

De Commission Historique
Révision datée du 28 février 2022 à 11:10 par L.strappazon (discussion | contributions) (Contenu remplacé par « local p = {} local langue = 'fr' local lang = mw.getLanguage( langue ) local dict = mw.loadData( 'module:Translate/data' ) function p.dict_to_csv() local res = '' for mot,translation in pairs(dict) do res = res .. mot .. ';' .. translation['de'] .. ';' .. translation['en'] .. ';' .. translation['fr'] .. '<br>' end return(res) end function p.translate(expr,langue) if dict[expr] then if dict[expr][langue] then return dict[expr][langue] elseif dic... »)

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

local p = {}
local langue = 'fr'
local lang = mw.getLanguage( langue )

local dict = mw.loadData( 'module:Translate/data' )

function p.dict_to_csv()
	local res = ''
	for mot,translation in pairs(dict) do
		res = res .. mot .. ';' ..  translation['de'] .. ';' .. translation['en'] .. ';' .. translation['fr'] .. '<br>'
	end
	return(res)
end

function p.translate(expr,langue)
	if dict[expr] then 
		if dict[expr][langue] then
			return dict[expr][langue]
		elseif dict[expr]['en'] then
			return dict[expr]['en']
		elseif dict[expr]['fr'] then
			return dict[expr]['fr']
		elseif dict[expr]['de'] then
			return dict[expr]['de']
		else return expr
		end
	else return expr end
end

function p.transl(frame)
	local expr,langue =frame.args[1],frame.args[2]
	if dict[expr] then 
		if dict[expr][langue] then
			return dict[expr][langue]
		elseif dict[expr]['en'] then
			return dict[expr]['en']
		elseif dict[expr]['fr'] then
			return dict[expr]['fr']
		elseif dict[expr]['de'] then
			return dict[expr]['de']
		else return expr
		end
	else return expr end
end

return p