Jump to content

[Release] Multiple Languagesystem


yeahs

Recommended Posts

A easy way to translate your script into more than one language.

-- [[ SHARED ]] --

Language = {};

Language["DE"] = {

	["Message1"] = "Hey, ich bin hier!",
	["Message2"] = "Mein Name ist %s, ich bin cool.",
	["Message3"] = "Hier sind meine Koordinaten - x: %s, y: %s, z: %s",

};

Language["EN"] = {
	["Message1"] = "Hey, I'm here!",
	["Message2"] = "My name is %s and I'm cool.",
	["Message3"] = "Here are my coordinates; x: %s, y: %s, z: %s",
};

-- [[ SERVER ]] --

function loc(player,text)
	if(not(getElementData(player,"Langauge")))then type = "DE" else type = getElementData(player,"Language")end
	local getText = Language[type][text];
	if(not(getText))then
		outputChatBox("ERROR: '"..text.."' not found, contact the team.",player,125,0,0);
	else
		return getText;
	end
end

--// Example
addCommandHandler("message",function(player)
	local x,y,z = getElementPosition(player);
	outputChatBox(loc(player,"Message1"),player,0,125,0);
	outputChatBox(loc(player,"Message2"):format(getPlayerName(player)),player,0,125,0);
	outputChatBox(loc(player,"Message3"):format(x,y,z),player,0,125,0);
end)

-- [[ CLIENT ]] --

function loc(text)
	if(not(getElementData(localPlayer,"Langauge")))then type = "DE" else type = getElementData(localPlayer,"Language")end
	local getText = Language[type][text];
	if(not(getText))then
		outputChatBox("ERROR: '"..text.."' not found, contact the team.",125,0,0);
	else
		return getText;
	end
end

https://github.com/raydNDev/MTASA/tree/master/NuetzlicheScripts/Languagesystem

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...