3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #include "PluginSys.h"
16 #include "Translator.h"
17 #include "LibrarySys.h"
18 #include "sm_stringutil.h"
20 static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
24 CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
26 pCtx->LocalToString(params[1], &filename);
28 /* Check if there is no extension */
29 const char *ext = g_LibSys.GetFileExtension(filename);
30 if (!ext || (strcmp(ext, "cfg") && strcmp(ext, "txt")))
33 static char new_file[PLATFORM_MAX_PATH];
34 UTIL_Format(new_file, sizeof(new_file), "%s.txt", filename);
38 index = g_Translator.FindOrAddPhraseFile(filename);
39 pl->AddLangFile(index);
44 static cell_t sm_SetGlobalTransTarget(IPluginContext *pContext, const cell_t *params)
46 g_SourceMod.SetGlobalTarget(params[1]);
51 REGISTER_NATIVES(langNativeS)
53 {"LoadTranslations", sm_LoadTranslations},
54 {"SetGlobalTransTarget", sm_SetGlobalTransTarget},