diff --git a/core/smn_lang.cpp b/core/smn_lang.cpp index c6da6f2a..d4d6101d 100644 --- a/core/smn_lang.cpp +++ b/core/smn_lang.cpp @@ -14,6 +14,8 @@ #include "PluginSys.h" #include "Translator.h" +#include "LibrarySys.h" +#include "sm_stringutil.h" static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params) { @@ -23,6 +25,16 @@ static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params) pCtx->LocalToString(params[1], &filename); + /* Check if there is no extension */ + const char *ext = g_LibSys.GetFileExtension(filename); + if (!ext || (strcmp(ext, "cfg") && strcmp(ext, "txt"))) + { + /* Append one */ + static char new_file[PLATFORM_MAX_PATH]; + UTIL_Format(new_file, sizeof(new_file), "%s.txt", filename); + filename = new_file; + } + index = g_Translator.FindOrAddPhraseFile(filename); pl->AddLangFile(index); diff --git a/plugins/include/lang.inc b/plugins/include/lang.inc index 1b45612e..f1d5b5df 100644 --- a/plugins/include/lang.inc +++ b/plugins/include/lang.inc @@ -22,6 +22,7 @@ /** * Loads a translation file for the plugin calling this native. + * If no extension is specified, .txt is assumed. * * @param path Translation file. * @noreturn