mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 15:46:13 +00:00
[FONTVIEW] Make hardcoded messages localizable (#5305)
- Move messages from OnInstall procedure to en-US resource file. - Applied the same changes to all language files, now it's available for translation into other languages. CORE-18952 Signed-off-by: Nikita Piatygorskiy <generalhammond16@gmail.com>
This commit is contained in:
parent
2e836fb339
commit
5ef3f347ad
26 changed files with 196 additions and 25 deletions
|
@ -58,24 +58,50 @@ FormatString(
|
|||
}
|
||||
|
||||
static void
|
||||
ErrorMsgBox(HWND hParent, DWORD dwMessageId, ...)
|
||||
FormatMsgBox(
|
||||
_In_ HWND hParent,
|
||||
_In_ DWORD dwMessageId,
|
||||
_In_ DWORD dwCaptionId,
|
||||
_In_ UINT uType,
|
||||
_In_ va_list args)
|
||||
{
|
||||
HLOCAL hMemCaption = NULL;
|
||||
HLOCAL hMemText = NULL;
|
||||
|
||||
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, dwMessageId, 0, (LPWSTR)&hMemText, 0, &args);
|
||||
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, dwCaptionId, 0, (LPWSTR)&hMemCaption, 0, NULL);
|
||||
|
||||
MessageBoxW(hParent, hMemText, hMemCaption, uType);
|
||||
LocalFree(hMemCaption);
|
||||
LocalFree(hMemText);
|
||||
}
|
||||
|
||||
static void
|
||||
ErrorMsgBox(
|
||||
HWND hParent,
|
||||
DWORD dwMessageId,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, dwMessageId);
|
||||
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, dwMessageId, 0, (LPWSTR)&hMemText, 0, &args);
|
||||
FormatMsgBox(hParent, dwMessageId, IDS_ERROR, MB_ICONERROR, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL, IDS_ERROR, 0, (LPWSTR)&hMemCaption, 0, NULL);
|
||||
static void
|
||||
SuccessMsgBox(
|
||||
HWND hParent,
|
||||
DWORD dwMessageId,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
MessageBoxW(hParent, hMemText, hMemCaption, MB_ICONERROR);
|
||||
|
||||
LocalFree(hMemCaption);
|
||||
LocalFree(hMemText);
|
||||
va_start(args, dwMessageId);
|
||||
FormatMsgBox(hParent, dwMessageId, IDS_SUCCESS, MB_ICONINFORMATION, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
int WINAPI
|
||||
|
@ -451,7 +477,6 @@ MainWnd_OnInstall(HWND hwnd)
|
|||
HKEY hKey;
|
||||
|
||||
SendDlgItemMessage(hwnd, IDC_DISPLAY, FVM_GETFULLNAME, 64, (LPARAM)szFullName);
|
||||
// MessageBoxW(hwnd, szFullName, L"Debug", MB_OK);
|
||||
|
||||
/* First, we have to find out if the font still exists */
|
||||
if (GetFileAttributes(g_fileName) == INVALID_FILE_ATTRIBUTES)
|
||||
|
@ -468,21 +493,17 @@ MainWnd_OnInstall(HWND hwnd)
|
|||
wcscat(szDestPath, L"\\Fonts\\");
|
||||
wcscat(szDestPath, pszFileName);
|
||||
|
||||
/* Debug Message */
|
||||
// MessageBoxW(hwnd, szDestPath, L"szDestPath", MB_OK);
|
||||
// MessageBoxW(hwnd, pszFileName, L"pszFileExt", MB_OK);
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (GetFileAttributesW(szDestPath) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
MessageBoxW(hwnd, L"This font is already installed!", L"Already Installed", MB_OK);
|
||||
ErrorMsgBox(hwnd, IDS_ERROR_ISINSTALLED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the font file */
|
||||
if (!CopyFileW(g_fileName, szDestPath, TRUE))
|
||||
{
|
||||
MessageBoxW(hwnd,L"Failed to copy the font file!", L"File Error", MB_OK);
|
||||
ErrorMsgBox(hwnd, IDS_ERROR_FONTCPY);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -494,7 +515,7 @@ MainWnd_OnInstall(HWND hwnd)
|
|||
&hKey);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
MessageBoxW(hwnd, L"Failed top open the fonts key!", L"Debug1", MB_OK);
|
||||
ErrorMsgBox(hwnd, IDS_ERROR_OPENKEY);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -504,10 +525,10 @@ MainWnd_OnInstall(HWND hwnd)
|
|||
0,
|
||||
REG_SZ,
|
||||
(LPBYTE)pszFileName,
|
||||
(wcslen(pszFileName) + 1) * sizeof(WCHAR));
|
||||
(DWORD)(wcslen(pszFileName) + 1) * sizeof(WCHAR));
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
MessageBoxW(hwnd, L"Failed to register the new font!", L"Debug2", MB_OK);
|
||||
ErrorMsgBox(hwnd, IDS_ERROR_REGISTER);
|
||||
RegCloseKey(hKey);
|
||||
return -1;
|
||||
}
|
||||
|
@ -519,7 +540,7 @@ MainWnd_OnInstall(HWND hwnd)
|
|||
SendMessageW(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
|
||||
|
||||
/* if all of this goes correctly, message the user about success */
|
||||
MessageBoxW(hwnd, L"Font Installation Completed.", L"Success", MB_OK);
|
||||
SuccessMsgBox(hwnd, IDS_COMPLETED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue