Skip to content

Minimalistic multi-language library designed for open.mp.

Notifications You must be signed in to change notification settings

Mergevos/open-language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

language

Mergevos

Minimalistic multi language library.

Installation

Simply install to your project:

sampctl install Mergevos/open-language

Include in your code and begin using the library:

#include <language>

Usage

Simply declare a new language like:

new Language: serbian;
new Language: english;

public OnGameModeInit()
{
	serbian = Language_Init("Serbian");
	english = Language_Init("English");
	return 1;
}

Add a translation key like:

Language_AddKey(serbian, "TESTKEY", "Supak %d");
Language_AddKey(serbian, "BUTTON_YES", "Daa");
Language_AddKey(serbian, "INFO", "Ja sam novi mali peder\nvolim vas");

Everytime a SendClientMessage was sent with this key as text, it will send the value. This also goes for GameTextForPlayer, SendPlayerMessageToPlayer, ShowPlayerDialog... No new send functions, only hooks. Full example:

public OnPlayerSpawn(playerid)
{
	Language_SetPlayer(playerid, serbian);
	Language_AddKey(serbian, "TESTKEY", "Supak %d");
	Language_AddKey(serbian, "BUTTON_YES", "Daa");
	Language_AddKey(serbian, "INFO", "Ja sam novi mali peder\nvolim vas");

	Language_AddKey(english, "TESTKEY", "Ass %d");
	Language_AddKey(english, "BUTTON_YES", "YES");
	Language_AddKey(english, "INFO", "I'm small gay\nlove yall");

	SendClientMessage(playerid, -1, "Testiramo scm %d %s", 0, ReturnPlayerName(playerid));
	SendClientMessage(playerid, -1, "TESTKEY", 33);

	SendClientMessageToAll(-1, "SCMTA test %d", 33);
	SendClientMessageToAll(-1, "");

	SendPlayerMessageToPlayer(playerid, playerid, "testiramo spmp");
	SendPlayerMessageToPlayer(playerid, playerid, "INFO");

	GameTextForPlayer(playerid, "BUTTON_YES", 3000, 4);

	Language_SetPlayer(playerid, english);

	SendClientMessage(playerid, -1, "Testiramo scm %d %s", 0, ReturnPlayerName(playerid));
	SendClientMessage(playerid, -1, "TESTKEY", 33);

	SendPlayerMessageToPlayer(playerid, playerid, "testiramo spmp");
	SendPlayerMessageToPlayer(playerid, playerid, "INFO");

	GameTextForPlayer(playerid, "BUTTON_YES", 3000, 4);


	SendClientMessageToAll(-1, "SCMTA test");
	SendClientMessageToAll(-1, "BUTTON_YES");

	new lang[MAX_LANG_NAME];
	Language_GetName(Language_GetPlayer(playerid), lang);
	SendClientMessage(playerid, -1, "Player's language is %s", lang);


	ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Caption", "INFO", "BUTTON_YES", "BUTTON_YES");

	
	return 1;
}

Testing

To test, simply run the package:

sampctl package run

About

Minimalistic multi-language library designed for open.mp.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages