mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2025-01-26 16:13:43 +01:00
GUI: Added the ability to switch languages
This commit is contained in:
parent
3cb3ace48a
commit
7c3be29282
@ -1 +1 @@
|
||||
Subproject commit d09fb3722cda34c082a1bb2645224a85af1d27e8
|
||||
Subproject commit bbf908d31cc0b66f62a205f3e6eaafb2439f47d2
|
@ -259,6 +259,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Localization.cpp" />
|
||||
<ClCompile Include="lvt.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@ -322,6 +323,7 @@
|
||||
<ClInclude Include="hooking.h" />
|
||||
<ClInclude Include="ep_private.h" />
|
||||
<ClInclude Include="ImmersiveFlyouts.h" />
|
||||
<ClInclude Include="Localization.h" />
|
||||
<ClInclude Include="lvt.h" />
|
||||
<ClInclude Include="osutility.h" />
|
||||
<ClInclude Include="queryversion.h" />
|
||||
|
142
ExplorerPatcher/Localization.cpp
Normal file
142
ExplorerPatcher/Localization.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
#include "Localization.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#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<EP_L10N_Language> 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<EP_L10N_Language>*)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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
26
ExplorerPatcher/Localization.h
Normal file
26
ExplorerPatcher/Localization.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#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
|
@ -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)
|
||||
{
|
||||
|
@ -323,6 +323,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
|
||||
|
||||
printf("[Symbols] Started \"Download symbols\" thread.\n");
|
||||
|
||||
EP_L10N_ApplyPreferredLanguageForCurrentThread();
|
||||
HMODULE hEPGui = LoadGuiModule();
|
||||
|
||||
RTL_OSVERSIONINFOW rovi;
|
||||
|
@ -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];
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <netlistmgr.h>
|
||||
#include <Psapi.h>
|
||||
#include <stdbool.h>
|
||||
#include "Localization.h"
|
||||
|
||||
#include "def.h"
|
||||
|
||||
|
211
ep_gui/GUI.c
211
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
|
||||
// <All other languages sorted in ascending order>
|
||||
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(
|
||||
|
@ -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"
|
||||
|
@ -88,6 +88,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\ExplorerPatcher\fmemopen.c" />
|
||||
<ClCompile Include="..\ExplorerPatcher\getline.c" />
|
||||
<ClCompile Include="..\ExplorerPatcher\Localization.cpp" />
|
||||
<ClCompile Include="..\ExplorerPatcher\utility.c" />
|
||||
<ClCompile Include="..\ep_weather_host_stub\ep_weather_host_i.c" />
|
||||
</ItemGroup>
|
||||
|
@ -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%
|
||||
|
@ -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%
|
||||
|
Loading…
x
Reference in New Issue
Block a user