1.1 --- a/core/smn_lang.cpp Fri May 09 08:22:39 2008 +0000
1.2 +++ b/core/smn_lang.cpp Sat May 10 09:23:55 2008 +0000
1.3 @@ -37,24 +37,25 @@
1.4
1.5 static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
1.6 {
1.7 - char *filename;
1.8 - unsigned int index;
1.9 + char *filename, *ext;
1.10 + char buffer[PLATFORM_MAX_PATH];
1.11 CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
1.12
1.13 pCtx->LocalToString(params[1], &filename);
1.14 + UTIL_Format(buffer, sizeof(buffer), "%s", filename);
1.15
1.16 - /* Check if there is no extension */
1.17 - const char *ext = g_LibSys.GetFileExtension(filename);
1.18 - if (!ext || (strcmp(ext, "cfg") && strcmp(ext, "txt")))
1.19 + /* Make sure there is no extension */
1.20 + if ((ext = strstr(buffer, ".txt")) != NULL
1.21 + || (ext = strstr(buffer, ".cfg")) != NULL)
1.22 {
1.23 - /* Append one */
1.24 - static char new_file[PLATFORM_MAX_PATH];
1.25 - UTIL_Format(new_file, sizeof(new_file), "%s.txt", filename);
1.26 - filename = new_file;
1.27 + /* Simple heuristic -- just see if it's at the end and terminate if so */
1.28 + if (ext - buffer == strlen(buffer) - 4)
1.29 + {
1.30 + *ext = '\0';
1.31 + }
1.32 }
1.33
1.34 - index = g_Translator.FindOrAddPhraseFile(filename);
1.35 - pl->AddLangFile(index);
1.36 + pl->GetPhrases()->AddPhraseFile(buffer);
1.37
1.38 return 1;
1.39 }