Added new language natives (bug 4613, r+a13=dvander).
This commit is contained in:
parent
0824e49000
commit
ca75d0d765
@ -104,6 +104,46 @@ static cell_t sm_GetLanguageInfo(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
CPlayer *player = g_Players.GetPlayerByIndex(params[1]);
|
||||
|
||||
if (!player || !player->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
|
||||
}
|
||||
|
||||
player->m_LangId = params[2];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetLanguageByCode(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *code;
|
||||
unsigned int langid;
|
||||
|
||||
pContext->LocalToString(params[1], &code);
|
||||
|
||||
if (g_Translator.GetLanguageByCode(code, &langid))
|
||||
return langid;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetLanguageByName(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *name;
|
||||
unsigned int langid;
|
||||
|
||||
pContext->LocalToString(params[1], &name);
|
||||
|
||||
if (g_Translator.GetLanguageByName(name, &langid))
|
||||
return langid;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(langNatives)
|
||||
{
|
||||
{"LoadTranslations", sm_LoadTranslations},
|
||||
@ -112,5 +152,8 @@ REGISTER_NATIVES(langNatives)
|
||||
{"GetServerLanguage", sm_GetServerLanguage},
|
||||
{"GetLanguageCount", sm_GetLanguageCount},
|
||||
{"GetLanguageInfo", sm_GetLanguageInfo},
|
||||
{"SetClientLanguage", sm_SetClientLanguage},
|
||||
{"GetLanguageByCode", sm_GetLanguageByCode},
|
||||
{"GetLanguageByName", sm_GetLanguageByName},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -94,3 +94,28 @@ native GetLanguageCount();
|
||||
*/
|
||||
native GetLanguageInfo(language, String:code[]="", codeLen=0, String:name[]="", nameLen=0);
|
||||
|
||||
/**
|
||||
* Sets the language number of a client.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param language Language number.
|
||||
* @noreturn
|
||||
* @error Invalid client index or client not in game.
|
||||
*/
|
||||
native SetClientLanguage(client, language);
|
||||
|
||||
/**
|
||||
* Retrieves the language number from a language code.
|
||||
*
|
||||
* @param code Language code (2-3 characters usually).
|
||||
* @return Language number. -1 if not found.
|
||||
*/
|
||||
native GetLanguageByCode(const String:code[]);
|
||||
|
||||
/**
|
||||
* Retrieves the language number from a language name.
|
||||
*
|
||||
* @param name Language name (case insensitive).
|
||||
* @return Language number. -1 if not found.
|
||||
*/
|
||||
native GetLanguageByName(const String:name[]);
|
||||
|
Loading…
Reference in New Issue
Block a user