-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the UI language was incorrectly determined by "Region Format"
- Loading branch information
Showing
5 changed files
with
604 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,91 @@ | ||
// WeaselDeployer.cpp : Defines the entry point for the application. | ||
// | ||
#include "stdafx.h" | ||
#include <WeaselUtility.h> | ||
#include <fstream> | ||
#include "WeaselDeployer.h" | ||
#include "Configurator.h" | ||
|
||
CAppModule _Module; | ||
|
||
static int Run(LPTSTR lpCmdLine); | ||
|
||
int APIENTRY _tWinMain(HINSTANCE hInstance, | ||
HINSTANCE hPrevInstance, | ||
LPTSTR lpCmdLine, | ||
int nCmdShow) { | ||
UNREFERENCED_PARAMETER(hPrevInstance); | ||
|
||
LCID lcid = GetUserDefaultLCID(); | ||
LANGID langId; | ||
if (lcid == 2052 || lcid == 3072 || lcid == 4100) { | ||
langId = SetThreadUILanguage( | ||
MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)); | ||
} else if (lcid == 1028 || lcid == 3076 || lcid == 5124) { | ||
langId = SetThreadUILanguage( | ||
MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)); | ||
} else { | ||
langId = SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); | ||
} | ||
SetThreadLocale(langId); | ||
|
||
HRESULT hRes = ::CoInitialize(NULL); | ||
// If you are running on NT 4.0 or higher you can use the following call | ||
// instead to make the EXE free threaded. This means that calls come in on a | ||
// random RPC thread. | ||
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); | ||
ATLASSERT(SUCCEEDED(hRes)); | ||
|
||
// this resolves ATL window thunking problem when Microsoft Layer for Unicode | ||
// (MSLU) is used | ||
::DefWindowProc(NULL, 0, 0, 0L); | ||
|
||
AtlInitCommonControls( | ||
ICC_BAR_CLASSES); // add flags to support other controls | ||
|
||
hRes = _Module.Init(NULL, hInstance); | ||
ATLASSERT(SUCCEEDED(hRes)); | ||
|
||
CreateDirectory(WeaselUserDataPath().c_str(), NULL); | ||
|
||
int ret = 0; | ||
HANDLE hMutex = CreateMutex(NULL, TRUE, L"WeaselDeployerExclusiveMutex"); | ||
if (!hMutex) { | ||
ret = 1; | ||
} else if (GetLastError() == ERROR_ALREADY_EXISTS) { | ||
ret = 1; | ||
} else { | ||
ret = Run(lpCmdLine); | ||
} | ||
|
||
if (hMutex) { | ||
CloseHandle(hMutex); | ||
} | ||
_Module.Term(); | ||
::CoUninitialize(); | ||
|
||
return ret; | ||
} | ||
|
||
static int Run(LPTSTR lpCmdLine) { | ||
Configurator configurator; | ||
configurator.Initialize(); | ||
bool deployment_scheduled = !wcscmp(L"/deploy", lpCmdLine); | ||
if (deployment_scheduled) { | ||
return configurator.UpdateWorkspace(); | ||
} | ||
|
||
bool dict_management = !wcscmp(L"/dict", lpCmdLine); | ||
if (dict_management) { | ||
return configurator.DictManagement(); | ||
} | ||
|
||
bool sync_user_dict = !wcscmp(L"/sync", lpCmdLine); | ||
if (sync_user_dict) { | ||
return configurator.SyncUserData(); | ||
} | ||
|
||
bool installing = !wcscmp(L"/install", lpCmdLine); | ||
return configurator.Run(installing); | ||
// WeaselDeployer.cpp : Defines the entry point for the application. | ||
// | ||
#include "stdafx.h" | ||
#include <WeaselUtility.h> | ||
#include <fstream> | ||
#include "WeaselDeployer.h" | ||
#include "Configurator.h" | ||
|
||
CAppModule _Module; | ||
|
||
static int Run(LPTSTR lpCmdLine); | ||
|
||
int APIENTRY _tWinMain(HINSTANCE hInstance, | ||
HINSTANCE hPrevInstance, | ||
LPTSTR lpCmdLine, | ||
int nCmdShow) { | ||
UNREFERENCED_PARAMETER(hPrevInstance); | ||
|
||
LANGID langId = GetUserDefaultUILanguage(); | ||
if (langId == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) || | ||
langId == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE)) { | ||
langId = MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED); | ||
} else if (langId == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL) || | ||
langId == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_HONGKONG) || | ||
langId == MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_MACAU)) { | ||
langId = MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL); | ||
} else { | ||
langId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); | ||
} | ||
SetThreadUILanguage(langId); | ||
SetThreadLocale(langId); | ||
|
||
HRESULT hRes = ::CoInitialize(NULL); | ||
// If you are running on NT 4.0 or higher you can use the following call | ||
// instead to make the EXE free threaded. This means that calls come in on a | ||
// random RPC thread. | ||
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); | ||
ATLASSERT(SUCCEEDED(hRes)); | ||
|
||
// this resolves ATL window thunking problem when Microsoft Layer for Unicode | ||
// (MSLU) is used | ||
::DefWindowProc(NULL, 0, 0, 0L); | ||
|
||
AtlInitCommonControls( | ||
ICC_BAR_CLASSES); // add flags to support other controls | ||
|
||
hRes = _Module.Init(NULL, hInstance); | ||
ATLASSERT(SUCCEEDED(hRes)); | ||
|
||
CreateDirectory(WeaselUserDataPath().c_str(), NULL); | ||
|
||
int ret = 0; | ||
HANDLE hMutex = CreateMutex(NULL, TRUE, L"WeaselDeployerExclusiveMutex"); | ||
if (!hMutex) { | ||
ret = 1; | ||
} else if (GetLastError() == ERROR_ALREADY_EXISTS) { | ||
ret = 1; | ||
} else { | ||
ret = Run(lpCmdLine); | ||
} | ||
|
||
if (hMutex) { | ||
CloseHandle(hMutex); | ||
} | ||
_Module.Term(); | ||
::CoUninitialize(); | ||
|
||
return ret; | ||
} | ||
|
||
static int Run(LPTSTR lpCmdLine) { | ||
Configurator configurator; | ||
configurator.Initialize(); | ||
bool deployment_scheduled = !wcscmp(L"/deploy", lpCmdLine); | ||
if (deployment_scheduled) { | ||
return configurator.UpdateWorkspace(); | ||
} | ||
|
||
bool dict_management = !wcscmp(L"/dict", lpCmdLine); | ||
if (dict_management) { | ||
return configurator.DictManagement(); | ||
} | ||
|
||
bool sync_user_dict = !wcscmp(L"/sync", lpCmdLine); | ||
if (sync_user_dict) { | ||
return configurator.SyncUserData(); | ||
} | ||
|
||
bool installing = !wcscmp(L"/install", lpCmdLine); | ||
return configurator.Run(installing); | ||
} |
Oops, something went wrong.