Lang:Lang_Add(code[], name[])
Lang_Remove(Lang:lang)
Lang_LoadFile(Lang:lang, filename[])
Lang_UnloadFile(Lang:lang, filename[] = "", fid = INVALID_LANG_FILE_ID)
Lang_Reload(Lang:lang)
Lang:Lang_Get(code[] = "", name[] = "")
Lang_SetName(Lang:lang, name[])
Lang_GetName(Lang:lang, name[], const size = sizeof(name))
Lang_ReturnName(Lang:lang)
Lang_SetCode(Lang:lang, code[])
Lang_GetCode(Lang:lang, code[], const size = sizeof(code))
Lang_ReturnCode(Lang:lang)
Lang_GetCodes(result[], const size = sizeof(result), const separator = '/', const bool:isuppercase = false)
Lang_ReturnCodes(const separator = '/', const bool:isuppercase = false)
Lang_IsValid(Lang:lang)
Lang_GetCount()
Lang_SetPlayerLang(playerid, Lang:lang)
Lang:Lang_GetPlayerLang(playerid)
Lang:Lang_SetPlayerLangByCode(playerid, code[])
Lang:Lang_SetPlayerLangByName(playerid, name[])
Lang_SetDefaultLang(Lang:lang)
Lang_GetDefaultLang()
Lang_GetText(Lang:lang, var[], text[], const size = sizeof(text), {Float, _}:...)
Lang_GetPlayerText(playerid, var[], text[], const size = sizeof(text), {Float, _}:...)
Lang_GetDefaultText(var[], text[], const size = sizeof(text), {Float, _}:...)
Lang_RemoveText(Lang:lang, var[])
Lang_IsTextExists(Lang:lang, var[])
Lang_printf(var[], {Float, _}:...)
Lang_printfex(Lang:lang, var[], {Float, _}:...)
Lang_print(var[], {Float, _}:...)
Lang_printex(Lang:lang, var[])
Lang_SendText(playerid, var[], {Float, _}:...)
Lang_SendTextToAll(var[], {Float, _}:...)
Lang_SendTextToPlayers(players[], var[], {Float, _}:...)
Lang_ShowDialog(playerid, dialogid, style, var_caption[], var_info[], var_button1[], var_button2[], {Float, _}:...)
Lang_GameText(playerid, time, style, var[], {Float, _}:...)
Lang_GameTextForAll(time, style, var[], {Float, _}:...)
Lang_CreatePlayerTextDraw(playerid, Float:x, Float:y, var[], {Float, _}:...)
Lang_PlayerTextDrawSetString(playerid, PlayerText:text, var[], {Float, _}:...)
HELLO_MSG = Hello
COLOR_RED = {FF0000}
COLOR_GREEN = {00FF00}
COLOR_WHITE = {FFFFFF}
NAME_ONE = \v(COLOR_RED)Alex\v(COLOR_WHITE)
NAME_TWO = \v(COLOR_GREEN)Peter\v(COLOR_WHITE)
MESSAGE_HELLO = \v(COLOR_WHITE)\v(HELLO_MSG) \v(NAME_ONE) and \v(NAME_TWO)
#include <a_samp>
#include <gvar>
#include <zlang>
enum e_LANG_INFO {
Lang:e_LANG_EN,
Lang:e_LANG_RU,
}
static
gLang[e_LANG_INFO];
main() {}
public OnGameModeInit()
{
// load languages
gLang[e_LANG_RU] = Lang_Add("ru", "Russian");
gLang[e_LANG_EN] = Lang_Add("en", "English");
Lang_LoadFile(gLang[e_LANG_RU], "ru.ini");
Lang_LoadFile(gLang[e_LANG_EN], "en.ini");
// set english as the default language
Lang_SetDefaultLang(gLang[e_LANG_EN]);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/ru", true, 3) == 0) {
Lang_SetPlayerLang(playerid, gLang[e_LANG_RU]);
Lang_SendText(playerid, "LANGUAGE_CHANGED");
return 1;
}
if (strcmp(cmdtext, "/en", true, 3) == 0) {
Lang_SetPlayerLang(playerid, gLang[e_LANG_EN]);
Lang_SendText(playerid, "LANGUAGE_CHANGED");
return 1;
}
if (strcmp(cmdtext, "/help", true, 5) == 0) {
Lang_SendText(playerid, "HELLO_MSG");
Lang_SendText(playerid, "COMMANDS_LIST");
return 1;
}
if (strcmp(cmdtext, "/help330", true, 5) == 0) {
Lang_SendText(playerid, "Hello, World!");
Lang_SendText(playerid, "Commands: /help, /en, /ru");
return 1;
}
return 0;
}
COLOR_GRAY = {CCCCCC}
LANGUAGE_CHANGED = \v(COLOR_GRAY)Now you are using english language.
HELLO_MSG = Hello, {00FF00}World!
COMMANDS_LIST = Commands: /help, /en, /ru
COLOR_GRAY = {CCCCCC}
LANGUAGE_CHANGED = \v(COLOR_GRAY)Теперь вы используете русский язык.
HELLO_MSG = Привет, {00FF00}Мир!
COMMANDS_LIST = Команды: /help, /en, /ru
# in zlang 3.3.0
Hello, World! = \v(HELLO_MSG)
Commands: /help, /en, /ru = \v(COMMANDS_LIST)
if (strcmp(cmdtext, "/help330", true, 5) == 0) {
Lang_SendText(playerid, "Hello, World!");
Lang_SendText(playerid, "Commands: /help, /en, /ru");
return 1;
}
COLOR_GRAY = {CCCCCC}
LANGUAGE_CHANGED = \v(COLOR_GRAY)Теперь вы используете русский язык.
HELLO_MSG = Привет, {00FF00}Мир!
COMMANDS_LIST = Команды: /help, /en, /ru
# in zlang 3.3.0
Hello, World! = \v(HELLO_MSG)
Commands: /help, /en, /ru = \v(COMMANDS_LIST)
Nope. Any existed algorithm for search by string keys on Pawn is slower than existed in GVar. I was made some tests compared to y_languages and GVar's is much faster.
|
Maybe faster than y_lang, that'd be even great if you could add them to the thread to see some comparison (if possible with source), but regular variables definitely are faster than gvar.
http://forum.sa-mp.com/showpost.php?...3&postcount=11 http://forum.sa-mp.com/showpost.php?...2&postcount=14 I'd say language is definitely a time critical because text is used everywhere. |
Sorry for bump,
is this possible with formatex.inc ? lets say i want to make message with %p format |