From 74b4a85ba172feebc98a236d2a1bfeead3da293a Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Fri, 22 Jul 2022 21:33:41 +0200 Subject: [PATCH] Put WinBoard language files in separate folder A new string option -languageDir is added. When this not an empty string it will be taken as the directory where WinBoard searches the *.lng translation files. The option is persistent in WinBoard. --- args.h | 1 + common.h | 1 + winboard/winboard.c | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/args.h b/args.h index 3e376e5..a345145 100644 --- a/args.h +++ b/args.h @@ -520,6 +520,7 @@ ArgDescriptor argDescriptors[] = { !XBOARD, (ArgIniType) SCP_NAMES }, { "themeNames", ArgString, (void *) &appData.themeNames, TRUE, (ArgIniType) "native -upf false -ub false -ubt false -pid \"\"\n" }, { "engineList", ArgFilename, (void *) &engineListFile, TRUE, (ArgIniType) "" }, + { "languageDir", ArgFilename, (void *) &appData.languageDir, !XBOARD, (ArgIniType) "" }, { "addMasterOption", ArgMaster, NULL, FALSE, INVALID }, { "installEngine", ArgInstall, (void *) &firstChessProgramNames, FALSE, (ArgIniType) "" }, { "installTheme", ArgInstall, (void *) &appData.themeNames, FALSE, (ArgIniType) "" }, diff --git a/common.h b/common.h index 1943341..6eb89df 100644 --- a/common.h +++ b/common.h @@ -750,6 +750,7 @@ typedef struct { char *serverFileName; char *serverMovesName; + char *languageDir; char *finger; Boolean suppressLoadMoves; int serverPause; diff --git a/winboard/winboard.c b/winboard/winboard.c index 191ac62..81d6f2f 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -383,6 +383,7 @@ LoadLanguageFile(char *name) languageBuf[--i] = k; + } i++; } @@ -459,6 +460,7 @@ void TranslateMenus(int addLanguage) { int i; + char buf[MSG_SIZ]; WIN32_FIND_DATA fileData; HANDLE hFind; #define IDM_English 1970 @@ -474,7 +476,8 @@ TranslateMenus(int addLanguage) } if(!addLanguage) return; - if((hFind = FindFirstFile("*.LNG", &fileData)) != INVALID_HANDLE_VALUE) { + snprintf(buf, MSG_SIZ, "%s%s*.LNG", appData.languageDir, *appData.languageDir ? "\\" : ""); + if((hFind = FindFirstFile(buf, &fileData)) != INVALID_HANDLE_VALUE) { HMENU mainMenu = GetMenu(hwndMain); HMENU subMenu = GetSubMenu(mainMenu, GetMenuItemCount(mainMenu)-1); AppendMenu(subMenu, MF_SEPARATOR, (UINT_PTR) 0, NULL); @@ -483,7 +486,8 @@ TranslateMenus(int addLanguage) do { char *p, *q = fileData.cFileName; int checkFlag = MF_UNCHECKED; - languageFile[i] = strdup(q); + snprintf(buf, MSG_SIZ, "%s%s%s", appData.languageDir, *appData.languageDir ? "\\" : "", q); + languageFile[i] = strdup(buf); if(barbaric && !strcmp(oldLanguage, q)) { checkFlag = MF_CHECKED; lastChecked = IDM_English + i + 1; -- 1.7.0.4