From 7c3be29282a312f7380224042be66e661c394dbe Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Tue, 21 Nov 2023 00:02:10 +0700 Subject: [PATCH] GUI: Added the ability to switch languages --- ExplorerPatcher-L10N | 2 +- ExplorerPatcher/ExplorerPatcher.vcxproj | 2 + ExplorerPatcher/Localization.cpp | 142 ++++++++++++++++ ExplorerPatcher/Localization.h | 26 +++ ExplorerPatcher/dllmain.c | 51 +----- ExplorerPatcher/symbols.c | 1 + ExplorerPatcher/updates.c | 3 + ExplorerPatcher/utility.h | 1 + ep_gui/GUI.c | 211 ++++++++++++++---------- ep_gui/GUI.h | 1 + ep_gui/ep_gui.vcxproj | 1 + ep_gui/resources/settings.reg | 3 + ep_gui/resources/settings10.reg | 3 + 13 files changed, 313 insertions(+), 134 deletions(-) create mode 100644 ExplorerPatcher/Localization.cpp create mode 100644 ExplorerPatcher/Localization.h diff --git a/ExplorerPatcher-L10N b/ExplorerPatcher-L10N index d09fb37..bbf908d 160000 --- a/ExplorerPatcher-L10N +++ b/ExplorerPatcher-L10N @@ -1 +1 @@ -Subproject commit d09fb3722cda34c082a1bb2645224a85af1d27e8 +Subproject commit bbf908d31cc0b66f62a205f3e6eaafb2439f47d2 diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index b6c92c5..dfc07a5 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -259,6 +259,7 @@ true true + true true @@ -322,6 +323,7 @@ + diff --git a/ExplorerPatcher/Localization.cpp b/ExplorerPatcher/Localization.cpp new file mode 100644 index 0000000..984381d --- /dev/null +++ b/ExplorerPatcher/Localization.cpp @@ -0,0 +1,142 @@ +#include "Localization.h" + +#include +#include + +#include "def.h" + +extern "C" +{ + +EP_L10N_Language LangIDToEPLanguage(LANGID wLanguage) +{ + EP_L10N_Language language = {}; + language.id = wLanguage; + GetLocaleInfoW(wLanguage, LOCALE_SNAME, language.wszId, ARRAYSIZE(language.wszId)); + GetLocaleInfoW(wLanguage, LOCALE_SLOCALIZEDLANGUAGENAME, language.wszDisplayName, ARRAYSIZE(language.wszDisplayName)); + return language; +} + +BOOL EP_L10N_ApplyPreferredLanguageForCurrentThread() +{ + BOOL rv = FALSE; + HKEY hKey = nullptr; + RegCreateKeyExW( + HKEY_CURRENT_USER, + TEXT(REGPATH), + 0, + nullptr, + REG_OPTION_NON_VOLATILE, + KEY_READ | KEY_WOW64_64KEY, + nullptr, + &hKey, + nullptr + ); + if (hKey == nullptr || hKey == INVALID_HANDLE_VALUE) + { + hKey = nullptr; + } + if (hKey) + { + DWORD dwPreferredLanguage = 0; + DWORD dwSize = sizeof(dwPreferredLanguage); + LSTATUS lres = RegQueryValueExW( + hKey, + TEXT("Language"), + nullptr, + nullptr, + (LPBYTE)&dwPreferredLanguage, + &dwSize + ); + if (lres == ERROR_SUCCESS && dwSize > 0) + { + EP_L10N_Language language = LangIDToEPLanguage(dwPreferredLanguage); + rv = SetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, language.wszId, nullptr); + } + RegCloseKey(hKey); + } + return rv; +} + +BOOL EP_L10N_GetCurrentUserLanguage(wchar_t* wszLanguage, int cch) +{ + BOOL bOk = FALSE; + ULONG ulNumLanguages = 0; + ULONG cchLanguagesBuffer = 0; + if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, nullptr, &cchLanguagesBuffer)) + { + wchar_t* wszLanguagesBuffer = (wchar_t*)malloc(cchLanguagesBuffer * sizeof(wchar_t)); + if (wszLanguagesBuffer) + { + if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer)) + { + wcscpy_s(wszLanguage, cch, wszLanguagesBuffer); + bOk = TRUE; + } + free(wszLanguagesBuffer); + } + } + if (!bOk) + { + wcscpy_s(wszLanguage, cch, L"en-US"); + } + return TRUE; +} + +BOOL EP_L10N_GetCurrentThreadLanguage(wchar_t* wszLanguage, int cch) +{ + BOOL bOk = FALSE; + ULONG ulNumLanguages = 0; + ULONG cchLanguagesBuffer = 0; + if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, nullptr, &cchLanguagesBuffer)) + { + wchar_t* wszLanguagesBuffer = (wchar_t*)malloc(cchLanguagesBuffer * sizeof(wchar_t)); + if (wszLanguagesBuffer) + { + if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer)) + { + wcscpy_s(wszLanguage, cch, wszLanguagesBuffer); + bOk = TRUE; + } + free(wszLanguagesBuffer); + } + } + if (!bOk) + { + wcscpy_s(wszLanguage, cch, L"en-US"); + } + return TRUE; +} + +void EP_L10N_EnumerateLanguages(HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, EP_L10N_EnumerateLanguagesProc_t pfnProc, void* data) +{ + std::vector languages; + + // English (US) is our primary language + languages.push_back(LangIDToEPLanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US))); + + // Add the rest below it + EnumResourceLanguagesW(hModule, lpType, lpName, [](HMODULE, LPCWSTR, LPCWSTR, WORD wLanguage, LONG_PTR lParam) -> BOOL + { + if (wLanguage != MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)) + { + EP_L10N_Language language = LangIDToEPLanguage(wLanguage); + ((std::vector*)lParam)->push_back(language); + } + return TRUE; + }, (LONG_PTR)&languages); + + // Sort the non-primary languages by localized display name + std::sort(languages.begin() + 1, languages.end(), [](const EP_L10N_Language& a, const EP_L10N_Language& b) -> bool + { + return wcscmp(a.wszDisplayName, b.wszDisplayName) < 0; + }); + + // Call the callback for each language + for (const EP_L10N_Language& language : languages) + { + pfnProc(&language, data); + } +} + +} diff --git a/ExplorerPatcher/Localization.h b/ExplorerPatcher/Localization.h new file mode 100644 index 0000000..1d4d1c5 --- /dev/null +++ b/ExplorerPatcher/Localization.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct EP_L10N_Language +{ + LANGID id; + wchar_t wszId[LOCALE_NAME_MAX_LENGTH]; + wchar_t wszDisplayName[LOCALE_NAME_MAX_LENGTH]; +} EP_L10N_Language; + +typedef void(*EP_L10N_EnumerateLanguagesProc_t)(const EP_L10N_Language* language, void* data); + +BOOL EP_L10N_ApplyPreferredLanguageForCurrentThread(); +BOOL EP_L10N_GetCurrentUserLanguage(wchar_t* wszLanguage, int cch); +BOOL EP_L10N_GetCurrentThreadLanguage(wchar_t* wszLanguage, int cch); +void EP_L10N_EnumerateLanguages(HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, EP_L10N_EnumerateLanguagesProc_t pfnProc, void* data); + +#ifdef __cplusplus +} +#endif diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 841512f..f9b9df8 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -198,6 +198,7 @@ DWORD S_Icon_Dark_Widgets = 0; BOOL g_bIsDesktopRaised = FALSE; #include "utility.h" +#include "Localization.h" #include "resource.h" #include "../ep_gui/resources/EPSharedResources.h" #ifdef USE_PRIVATE_INTERFACES @@ -6843,54 +6844,9 @@ void WINAPI LoadSettings(LPARAM lParam) NULL, wszWeatherLanguage, &dwSize - )) + ) != ERROR_SUCCESS || wszWeatherLanguage[0] == 0) { - BOOL bOk = FALSE; - ULONG ulNumLanguages = 0; - LPCWSTR wszLanguagesBuffer = NULL; - ULONG cchLanguagesBuffer = 0; - if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer)) - { - if (wszLanguagesBuffer = malloc(cchLanguagesBuffer * sizeof(WCHAR))) - { - if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer)) - { - wcscpy_s(wszWeatherLanguage, MAX_PATH, wszLanguagesBuffer); - bOk = TRUE; - } - free(wszLanguagesBuffer); - } - } - if (!bOk) - { - wcscpy_s(wszWeatherLanguage, MAX_PATH, L"en-US"); - } - } - else - { - if (wszWeatherLanguage[0] == 0) - { - BOOL bOk = FALSE; - ULONG ulNumLanguages = 0; - LPCWSTR wszLanguagesBuffer = NULL; - ULONG cchLanguagesBuffer = 0; - if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer)) - { - if (wszLanguagesBuffer = malloc(cchLanguagesBuffer * sizeof(WCHAR))) - { - if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer)) - { - wcscpy_s(wszWeatherLanguage, MAX_PATH, wszLanguagesBuffer); - bOk = TRUE; - } - free(wszLanguagesBuffer); - } - } - if (!bOk) - { - wcscpy_s(wszWeatherLanguage, MAX_PATH, L"en-US"); - } - } + EP_L10N_GetCurrentUserLanguage(wszWeatherLanguage, MAX_PATH); } if (epw) { @@ -11265,6 +11221,7 @@ DWORD InformUserAboutCrash(LPVOID unused) CrashCounterSettings cfg; GetCrashCounterSettings(&cfg); + EP_L10N_ApplyPreferredLanguageForCurrentThread(); HMODULE hEPGui = LoadGuiModule(); if (!hEPGui) { diff --git a/ExplorerPatcher/symbols.c b/ExplorerPatcher/symbols.c index 090472e..a6468f4 100644 --- a/ExplorerPatcher/symbols.c +++ b/ExplorerPatcher/symbols.c @@ -323,6 +323,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params) printf("[Symbols] Started \"Download symbols\" thread.\n"); + EP_L10N_ApplyPreferredLanguageForCurrentThread(); HMODULE hEPGui = LoadGuiModule(); RTL_OSVERSIONINFOW rovi; diff --git a/ExplorerPatcher/updates.c b/ExplorerPatcher/updates.c index e97a739..d80a8bd 100644 --- a/ExplorerPatcher/updates.c +++ b/ExplorerPatcher/updates.c @@ -548,6 +548,7 @@ BOOL IsUpdateAvailableHelper( wszMsg[0] = 0; WCHAR wszMsgFormat[500]; + EP_L10N_ApplyPreferredLanguageForCurrentThread(); HMODULE hEPGui = LoadGuiModule(); if (LoadStringW(hEPGui, IDS_UPDATES_PROMPT, wszMsgFormat, ARRAYSIZE(wszMsgFormat))) { @@ -871,6 +872,7 @@ BOOL ShowUpdateSuccessNotification( __x_ABI_CWindows_CUI_CNotifications_CIToastNotification** toast ) { + EP_L10N_ApplyPreferredLanguageForCurrentThread(); HMODULE hEPGui = LoadGuiModule(); wchar_t buf[TOAST_BUFSIZ]; @@ -952,6 +954,7 @@ BOOL InstallUpdatesIfAvailable( DWORD dwUpdatePolicy ) { + EP_L10N_ApplyPreferredLanguageForCurrentThread(); HMODULE hEPGui = LoadGuiModule(); wchar_t wszInfoURL[MAX_PATH]; diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index ab0d3b2..f613a09 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -25,6 +25,7 @@ #include #include #include +#include "Localization.h" #include "def.h" diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index 115914a..ce04235 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -5,8 +5,8 @@ DEFINE_GUID(LiveSetting_Property_GUID, 0xc12bcd8e, 0x2a8e, 0x4950, 0x8a, 0xe7, 0 TCHAR GUI_title[260]; FILE* AuditFile = NULL; -LANGID locale; -WCHAR wszLanguage[MAX_PATH]; +WCHAR wszLanguage[LOCALE_NAME_MAX_LENGTH]; +WCHAR wszThreadLanguage[LOCALE_NAME_MAX_LENGTH]; void* GUI_FileMapping = NULL; DWORD GUI_FileSize = 0; BOOL g_darkModeEnabled = FALSE; @@ -894,7 +894,7 @@ static void GUI_SetSection(GUI* _this, BOOL bCheckEnablement, int dwSection) RegCloseKey(hKey); } -void GUI_SubstituteLocalizedString(wchar_t* str, size_t cch) +static void GUI_SubstituteLocalizedString(wchar_t* str, size_t cch) { // %R:1212% // ^^^^ The resource ID @@ -920,6 +920,58 @@ void GUI_SubstituteLocalizedString(wchar_t* str, size_t cch) // TODO Check if the numbers are okay } +static void GUI_EnumerateLanguagesCallback(const EP_L10N_Language* language, void* data) +{ + HMENU hMenu = data; + + MENUITEMINFOW menuInfo; + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); + menuInfo.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE; + menuInfo.wID = language->id + 1; + menuInfo.dwItemData = NULL; + menuInfo.fType = MFT_STRING; + menuInfo.dwTypeData = (LPWSTR)language->wszDisplayName; // Copied by the system + menuInfo.cch = (UINT)wcslen(language->wszDisplayName); + InsertMenuItemW(hMenu, 2, FALSE, &menuInfo); +} + +static void GUI_PopulateLanguageSelectorMenu(HMENU hMenu) +{ + // Follow system setting (default) + wchar_t wszItemTitle[128]; + wszItemTitle[0] = 0; + LoadStringW(hModule, IDS_AT_SWS_COLORSCHEME_0, wszItemTitle, ARRAYSIZE(wszItemTitle)); + + MENUITEMINFOW menuInfo; + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); + menuInfo.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE; + menuInfo.wID = 0 + 1; + menuInfo.dwItemData = NULL; + menuInfo.fType = MFT_STRING; + menuInfo.dwTypeData = wszItemTitle; + menuInfo.cch = (UINT)wcslen(wszItemTitle); + + InsertMenuItemW(hMenu, 0, FALSE, &menuInfo); + + // -------------------- + menuInfo.fMask = MIIM_TYPE; + menuInfo.fType = MFT_SEPARATOR; + InsertMenuItemW(hMenu, 0, FALSE, &menuInfo); + + // English + // + EP_L10N_EnumerateLanguages(hModule, RT_STRING, MAKEINTRESOURCEW(IDS_TB / 16 + 1), GUI_EnumerateLanguagesCallback, hMenu); +} + +static void GUI_UpdateLanguages() +{ + EP_L10N_ApplyPreferredLanguageForCurrentThread(); + EP_L10N_GetCurrentUserLanguage(wszLanguage, ARRAYSIZE(wszLanguage)); + EP_L10N_GetCurrentThreadLanguage(wszThreadLanguage, ARRAYSIZE(wszThreadLanguage)); +} + static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) { GUI* _this; @@ -1003,7 +1055,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS; RECT rcText; DWORD dwMinWidthDp = 480; - if (!wcscmp(wszLanguage, L"nl-NL")) dwMinWidthDp = 600; + if (!wcscmp(wszThreadLanguage, L"nl-NL")) dwMinWidthDp = 600; DWORD dwMaxHeight = 0, dwMaxWidth = (DWORD)(dwMinWidthDp * (_this->dpi.x / 96.0)); BOOL bTabOrderHit = FALSE; DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right; @@ -2237,52 +2289,59 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) if (p) *p = 0; numChoices = atoi(line + 3); hMenu = CreatePopupMenu(); - for (unsigned int i = 0; i < numChoices; ++i) + if (numChoices == 10001) { - char* l = malloc(MAX_LINE_LENGTH * sizeof(char)); - numChRd = getline(&l, &bufsiz, f); - if (strncmp(l, ";x ", 3)) + GUI_PopulateLanguageSelectorMenu(hMenu); + } + else + { + for (unsigned int i = 0; i < numChoices; ++i) { - free(l); - i--; - continue; + char* l = malloc(MAX_LINE_LENGTH * sizeof(char)); + numChRd = getline(&l, &bufsiz, f); + if (strncmp(l, ";x ", 3)) + { + free(l); + i--; + continue; + } + char* p = strchr(l + 3, ' '); + if (p) *p = 0; + char* ln = p + 1; + p = strchr(p + 1, '\r'); + if (p) *p = 0; + p = strchr(p + 1, '\n'); + if (p) *p = 0; + + wchar_t* miText = malloc(MAX_PATH * sizeof(wchar_t)); + MultiByteToWideChar( + CP_UTF8, + MB_PRECOMPOSED, + ln, + MAX_PATH, + miText, + MAX_PATH + ); + GUI_SubstituteLocalizedString(miText, MAX_PATH); + + MENUITEMINFOW menuInfo; + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); + menuInfo.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE; + menuInfo.wID = atoi(l + 3) + 1; + menuInfo.dwItemData = l; + menuInfo.fType = MFT_STRING; + menuInfo.dwTypeData = miText; + menuInfo.cch = strlen(ln); + InsertMenuItemW( + hMenu, + i, + TRUE, + &menuInfo + ); + + free(miText); } - char* p = strchr(l + 3, ' '); - if (p) *p = 0; - char* ln = p + 1; - p = strchr(p + 1, '\r'); - if (p) *p = 0; - p = strchr(p + 1, '\n'); - if (p) *p = 0; - - wchar_t* miText = malloc(MAX_PATH * sizeof(wchar_t)); - MultiByteToWideChar( - CP_UTF8, - MB_PRECOMPOSED, - ln, - MAX_PATH, - miText, - MAX_PATH - ); - GUI_SubstituteLocalizedString(miText, MAX_PATH); - - MENUITEMINFOW menuInfo; - ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); - menuInfo.cbSize = sizeof(MENUITEMINFOW); - menuInfo.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE; - menuInfo.wID = atoi(l + 3) + 1; - menuInfo.dwItemData = l; - menuInfo.fType = MFT_STRING; - menuInfo.dwTypeData = miText; - menuInfo.cch = strlen(ln); - InsertMenuItemW( - hMenu, - i, - TRUE, - &menuInfo - ); - - free(miText); } } else if (bInput) @@ -2564,7 +2623,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) menuInfo.cbSize = sizeof(MENUITEMINFOW); menuInfo.fMask = MIIM_STATE; menuInfo.fState = MFS_CHECKED; - SetMenuItemInfo(hMenu, vvv, FALSE, &menuInfo); + SetMenuItemInfoW(hMenu, vvv, FALSE, &menuInfo); } if (hDC && !bInvert && !bBool && !bJustCheck) { @@ -2782,6 +2841,15 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) &value, sizeof(DWORD) ); + if (!wcscmp(name, L"Language")) + { + GUI_UpdateLanguages(); + POINT pt; + pt.x = 0; + pt.y = 0; + _this->bCalcExtent = TRUE; + GUI_Build(0, hwnd, pt); + } } } InvalidateRect(hwnd, NULL, FALSE); @@ -2792,13 +2860,16 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } if (bChoice || bChoiceLefted) { - for (unsigned int i = 0; i < numChoices; ++i) + for (unsigned int i = 0; ; ++i) { - MENUITEMINFOA menuInfo; - ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA)); - menuInfo.cbSize = sizeof(MENUITEMINFOA); + MENUITEMINFOW menuInfo; + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); menuInfo.fMask = MIIM_DATA; - GetMenuItemInfoA(hMenu, i, TRUE, &menuInfo); + if (!GetMenuItemInfoW(hMenu, i, TRUE, &menuInfo)) + { + break; + } if (menuInfo.dwItemData) { free(menuInfo.dwItemData); @@ -3826,39 +3897,7 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin wprintf(L"Running on Windows %d, OS Build %d.%d.%d.%d.\n", IsWindows11() ? 11 : 10, global_rovi.dwMajorVersion, global_rovi.dwMinorVersion, global_rovi.dwBuildNumber, global_ubr); - locale = GetUserDefaultUILanguage(); - dwSize = LOCALE_NAME_MAX_LENGTH; - if (hKey) - { - RegQueryValueExW( - hKey, - TEXT("Language"), - 0, - NULL, - &locale, - &dwSize - ); - } - BOOL bOk = FALSE; - ULONG ulNumLanguages = 0; - LPCWSTR wszLanguagesBuffer = NULL; - ULONG cchLanguagesBuffer = 0; - if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer)) - { - if (wszLanguagesBuffer = malloc(cchLanguagesBuffer * sizeof(WCHAR))) - { - if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer)) - { - wcscpy_s(wszLanguage, MAX_PATH, wszLanguagesBuffer); - bOk = TRUE; - } - free(wszLanguagesBuffer); - } - } - if (!bOk) - { - wcscpy_s(wszLanguage, MAX_PATH, L"en-US"); - } + GUI_UpdateLanguages(); wchar_t wszPath[MAX_PATH]; ZeroMemory( diff --git a/ep_gui/GUI.h b/ep_gui/GUI.h index 93868ae..16691dd 100644 --- a/ep_gui/GUI.h +++ b/ep_gui/GUI.h @@ -23,6 +23,7 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #include "resources/resource.h" #include "../ExplorerPatcher/getline.h" #include "../ExplorerPatcher/fmemopen.h" +#include "../ExplorerPatcher/Localization.h" #include "../ExplorerPatcher/utility.h" #include "../ep_weather_host/ep_weather.h" #include "../ep_weather_host/ep_weather_host_h.h" diff --git a/ep_gui/ep_gui.vcxproj b/ep_gui/ep_gui.vcxproj index 04af69d..e0f32ff 100644 --- a/ep_gui/ep_gui.vcxproj +++ b/ep_gui/ep_gui.vcxproj @@ -88,6 +88,7 @@ + diff --git a/ep_gui/resources/settings.reg b/ep_gui/resources/settings.reg index 38bc663..e1a36ad 100644 --- a/ep_gui/resources/settings.reg +++ b/ep_gui/resources/settings.reg @@ -769,6 +769,9 @@ ;https://github.com/valinet/ExplorerPatcher/wiki/Frequently-asked-questions ;y %R:2011% 🡕 ;https://github.com/valinet/ExplorerPatcher/wiki/Settings-management +[HKEY_CURRENT_USER\Software\ExplorerPatcher] +;z 10001 %R:1533% +"Language"=dword:00000000 ;u %R:2012% ;import ;u %R:2013% diff --git a/ep_gui/resources/settings10.reg b/ep_gui/resources/settings10.reg index 613a8bc..329142e 100644 --- a/ep_gui/resources/settings10.reg +++ b/ep_gui/resources/settings10.reg @@ -592,6 +592,9 @@ ;https://github.com/valinet/ExplorerPatcher/wiki/Frequently-asked-questions ;y %R:2011% 🡕 ;https://github.com/valinet/ExplorerPatcher/wiki/Settings-management +[HKEY_CURRENT_USER\Software\ExplorerPatcher] +;z 10001 %R:1533% +"Language"=dword:00000000 ;u %R:2012% ;import ;u %R:2013%