mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Add %l format specifier and SetTranslationTarget() native
This commit is contained in:
parent
4d97a24dd8
commit
8831166705
@ -4431,6 +4431,14 @@ static cell AMX_NATIVE_CALL LookupLangKey(AMX *amx, cell *params)
|
|||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SetGlobalTransTarget(client)
|
||||||
|
static cell AMX_NATIVE_CALL SetGlobalTransTarget(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
g_langMngr.SetDefLang(params[1]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
|
||||||
// has_map_ent_class(const classname[])
|
// has_map_ent_class(const classname[])
|
||||||
static cell AMX_NATIVE_CALL has_map_ent_class(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL has_map_ent_class(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
@ -4629,6 +4637,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
|
|||||||
{"GetLangTransKey", GetLangTransKey},
|
{"GetLangTransKey", GetLangTransKey},
|
||||||
{"LibraryExists", LibraryExists},
|
{"LibraryExists", LibraryExists},
|
||||||
{"LookupLangKey", LookupLangKey},
|
{"LookupLangKey", LookupLangKey},
|
||||||
|
{"SetGlobalTransTarget", SetGlobalTransTarget},
|
||||||
{"PrepareArray", PrepareArray},
|
{"PrepareArray", PrepareArray},
|
||||||
{"ShowSyncHudMsg", ShowSyncHudMsg},
|
{"ShowSyncHudMsg", ShowSyncHudMsg},
|
||||||
{"is_rukia_a_hag", is_rukia_a_hag},
|
{"is_rukia_a_hag", is_rukia_a_hag},
|
||||||
|
@ -650,16 +650,26 @@ reswitch:
|
|||||||
arg++;
|
arg++;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
|
case 'l':
|
||||||
{
|
{
|
||||||
CHECK_ARGS(1);
|
cell target;
|
||||||
cell addr = params[arg++];
|
if (ch == 'L')
|
||||||
|
{
|
||||||
|
CHECK_ARGS(1);
|
||||||
|
target = params[arg++];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CHECK_ARGS(0);
|
||||||
|
target = g_langMngr.GetDefLang();
|
||||||
|
}
|
||||||
int len;
|
int len;
|
||||||
const char *key = get_amxstring(amx, params[arg++], 3, len);
|
const char *key = get_amxstring(amx, params[arg++], 3, len);
|
||||||
const char *def = translate(amx, addr, key);
|
const char *def = translate(amx, target, key);
|
||||||
if (!def)
|
if (!def)
|
||||||
{
|
{
|
||||||
static char buf[255];
|
static char buf[255];
|
||||||
UTIL_Format(buf, sizeof(buf)-1, "ML_NOTFOUND: %s", key);
|
UTIL_Format(buf, sizeof(buf) - 1, "ML_NOTFOUND: %s", key);
|
||||||
def = buf;
|
def = buf;
|
||||||
}
|
}
|
||||||
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
|
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
|
||||||
|
@ -60,3 +60,16 @@ native AddTranslation(const lang[3], TransKey:key, const phrase[]);
|
|||||||
* or LANG_SERVER
|
* or LANG_SERVER
|
||||||
*/
|
*/
|
||||||
native LookupLangKey(Output[], OutputSize, const Key[], &id);
|
native LookupLangKey(Output[], OutputSize, const Key[], &id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the global language target.
|
||||||
|
*
|
||||||
|
* @note This is useful for creating functions
|
||||||
|
* that will be compatible with the %l format specifier. Note that invalid
|
||||||
|
* indexes can be specified but the error will occur during translation,
|
||||||
|
* not during this function call.
|
||||||
|
*
|
||||||
|
* @param client Client index or LANG_SERVER
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native SetGlobalTransTarget(client);
|
||||||
|
Loading…
Reference in New Issue
Block a user