Merge pull request #229 from Arkshine/feature/trans-format-and-native
Add %l format specifier and SetTranslationTarget() native (bug 6331)
This commit is contained in:
commit
a59b72f96a
|
@ -4418,6 +4418,14 @@ static cell AMX_NATIVE_CALL LookupLangKey(AMX *amx, cell *params)
|
|||
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[])
|
||||
static cell AMX_NATIVE_CALL has_map_ent_class(AMX *amx, cell *params)
|
||||
{
|
||||
|
@ -4615,6 +4623,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
|
|||
{"GetLangTransKey", GetLangTransKey},
|
||||
{"LibraryExists", LibraryExists},
|
||||
{"LookupLangKey", LookupLangKey},
|
||||
{"SetGlobalTransTarget", SetGlobalTransTarget},
|
||||
{"PrepareArray", PrepareArray},
|
||||
{"ShowSyncHudMsg", ShowSyncHudMsg},
|
||||
{"is_rukia_a_hag", is_rukia_a_hag},
|
||||
|
|
|
@ -650,12 +650,22 @@ reswitch:
|
|||
arg++;
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
{
|
||||
cell target;
|
||||
if (ch == 'L')
|
||||
{
|
||||
CHECK_ARGS(1);
|
||||
cell addr = params[arg++];
|
||||
target = params[arg++];
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_ARGS(0);
|
||||
target = g_langMngr.GetDefLang();
|
||||
}
|
||||
int 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)
|
||||
{
|
||||
static char buf[255];
|
||||
|
|
|
@ -60,3 +60,16 @@ native AddTranslation(const lang[3], TransKey:key, const phrase[]);
|
|||
* or LANG_SERVER
|
||||
*/
|
||||
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