From 1ee7095e4147b1821d5d07cb9f196a8dc7f8a63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Wed, 23 Aug 2006 14:11:39 +0200 Subject: [PATCH] regedit: Put language-dependent strings in resources. --- programs/regedit/En.rc | 16 ++++++++++++++++ programs/regedit/Pl.rc | 16 ++++++++++++++++ programs/regedit/about.c | 4 +++- programs/regedit/childwnd.c | 2 +- programs/regedit/framewnd.c | 15 +++++++++++---- programs/regedit/listview.c | 24 ++++++++++++++++-------- programs/regedit/main.c | 3 ++- programs/regedit/main.h | 2 +- programs/regedit/resource.h | 8 ++++++++ 9 files changed, 74 insertions(+), 16 deletions(-) diff --git a/programs/regedit/En.rc b/programs/regedit/En.rc index 8db28592349..62b5c1fd961 100644 --- a/programs/regedit/En.rc +++ b/programs/regedit/En.rc @@ -363,6 +363,22 @@ BEGIN IDS_NOTFOUND "Search string '%s' not found" END +STRINGTABLE DISCARDABLE +BEGIN + IDS_FILEDIALOG_IMPORT_TITLE "Import Registry File" + IDS_FILEDIALOG_EXPORT_TITLE "Export Registry File" + IDS_FILEDIALOG_FILTER "Registration Files\0*.reg\0Win9x/NT4 Registration Files (REGEDIT4)\0*.reg\0All Files (*.*)\0*.*\0\0" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_REGISTRY_ROOT_NAME "My Computer" + IDS_REGISTRY_DEFAULT_VALUE "(Default)" + IDS_REGISTRY_VALUE_NOT_SET "(value not set)" + IDS_REGISTRY_VALUE_CANT_DISPLAY "(cannot display value)" + IDS_REGISTRY_UNKNOWN_TYPE "(unknown %d)" +END + /*****************************************************************/ diff --git a/programs/regedit/Pl.rc b/programs/regedit/Pl.rc index 934e93bd655..48c50d7c1dc 100644 --- a/programs/regedit/Pl.rc +++ b/programs/regedit/Pl.rc @@ -282,6 +282,22 @@ BEGIN IDS_NOTFOUND "Nie udało się wyszukać ciągu '%s'" END +STRINGTABLE DISCARDABLE +BEGIN + IDS_FILEDIALOG_IMPORT_TITLE "Importuj plik rejestrów" + IDS_FILEDIALOG_EXPORT_TITLE "Eksportuj plik rejestrów" + IDS_FILEDIALOG_FILTER "Pliki rejestrów\0*.reg\0Pliki rejestrów Win9x/NT4 (REGEDIT4)\0*.reg\0Wszystkie pliki (*.*)\0*.*\0\0" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_REGISTRY_ROOT_NAME "Mój komputer" + IDS_REGISTRY_DEFAULT_VALUE "(Domyślna)" + IDS_REGISTRY_VALUE_NOT_SET "(wartość nie ustalona)" + IDS_REGISTRY_VALUE_CANT_DISPLAY "(nie mogę wyświetlić wartości)" + IDS_REGISTRY_UNKNOWN_TYPE "(nieznany: %d)" +END + /*****************************************************************/ diff --git a/programs/regedit/about.c b/programs/regedit/about.c index 117b63ed986..7258a4dd28a 100644 --- a/programs/regedit/about.c +++ b/programs/regedit/about.c @@ -28,5 +28,7 @@ void ShowAboutBox(HWND hWnd) { - ShellAbout(hWnd, _T("Registry Editor"), _T(""), LoadIcon(hInst, MAKEINTRESOURCE(IDI_REGEDIT))); + TCHAR title[64]; + LoadString(hInst, IDS_APP_TITLE, title, COUNT_OF(title)); + ShellAbout(hWnd, title, _T(""), LoadIcon(hInst, MAKEINTRESOURCE(IDI_REGEDIT))); } diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c index 49adfd167e4..62c00b083bc 100644 --- a/programs/regedit/childwnd.c +++ b/programs/regedit/childwnd.c @@ -211,7 +211,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa case WM_CREATE: g_pChildWnd = pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd)); if (!pChildWnd) return 0; - _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); + LoadString(hInst, IDS_REGISTRY_ROOT_NAME, pChildWnd->szPath, MAX_PATH); pChildWnd->nSplitPos = 250; pChildWnd->hWnd = hWnd; pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW); diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index bac86ee49d1..9dd73fdec43 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -260,15 +260,18 @@ static UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W TCHAR FileNameBuffer[_MAX_PATH]; TCHAR FileTitleBuffer[_MAX_PATH]; +TCHAR FilterBuffer[_MAX_PATH]; -static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) +static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME *pofn) { memset(pofn, 0, sizeof(OPENFILENAME)); pofn->lStructSize = sizeof(OPENFILENAME); pofn->hwndOwner = hWnd; pofn->hInstance = hInst; - pofn->lpstrFilter = _T("Registration Files\0*.reg\0Win9x/NT4 Registration Files (REGEDIT4)\0*.reg\0All Files (*.*)\0*.*\0\0"); + if (FilterBuffer[0] == 0) + LoadString(hInst, IDS_FILEDIALOG_FILTER, FilterBuffer, _MAX_PATH); + pofn->lpstrFilter = FilterBuffer; pofn->nFilterIndex = 1; pofn->lpstrFile = FileNameBuffer; pofn->nMaxFile = _MAX_PATH; @@ -292,9 +295,11 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) static BOOL ImportRegistryFile(HWND hWnd) { OPENFILENAME ofn; + TCHAR title[128]; InitOpenFileName(hWnd, &ofn); - ofn.lpstrTitle = _T("Import Registry File"); + LoadString(hInst, IDS_FILEDIALOG_IMPORT_TITLE, title, COUNT_OF(title)); + ofn.lpstrTitle = title; /* ofn.lCustData = ;*/ if (GetOpenFileName(&ofn)) { if (!import_registry_file(ofn.lpstrFile)) { @@ -330,10 +335,12 @@ static BOOL ExportRegistryFile(HWND hWnd) { OPENFILENAME ofn; TCHAR ExportKeyPath[_MAX_PATH]; + TCHAR title[128]; ExportKeyPath[0] = _T('\0'); InitOpenFileName(hWnd, &ofn); - ofn.lpstrTitle = _T("Export Registry File"); + LoadString(hInst, IDS_FILEDIALOG_EXPORT_TITLE, title, COUNT_OF(title)); + ofn.lpstrTitle = title; /* ofn.lCustData = ;*/ ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER; ofn.lpfnHook = ImportRegistryFile_OFNHookProc; diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index 7b74ac4241c..a57a3c644c6 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -52,6 +52,7 @@ static BOOL g_invertSort = FALSE; static LPTSTR g_valueName; static LPTSTR g_currentPath; static HKEY g_currentRootKey; +static TCHAR g_szValueNotSet[64]; #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1) static int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 }; @@ -158,15 +159,13 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, index = ListView_InsertItem(hwndLV, &item); if (index != -1) { /* LPTSTR pszText = NULL; */ - static TCHAR pszText[] = {'(','c','a','n','n','o','t',' ','d','i','s','p','l','a','y',' ','v','a','l','u','e',')',0}; switch (dwValType) { case REG_SZ: case REG_EXPAND_SZ: if (ValBuf) { ListView_SetItemText(hwndLV, index, 2, ValBuf); } else { - static TCHAR textT[] = {'(','n','o','t',' ','s','e','t',')',0}; - ListView_SetItemText(hwndLV, index, 2, textT); + ListView_SetItemText(hwndLV, index, 2, g_szValueNotSet); } break; case REG_DWORD: { @@ -192,9 +191,13 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, ListView_SetItemText(hwndLV, index, 2, ValBuf); break; default: + { /* lpsRes = convertHexToHexCSV(lpbData, dwLen); */ - ListView_SetItemText(hwndLV, index, 2, pszText); + TCHAR szText[128]; + LoadString(hInst, IDS_REGISTRY_VALUE_CANT_DISPLAY, szText, COUNT_OF(szText)); + ListView_SetItemText(hwndLV, index, 2, szText); break; + } } } } @@ -263,9 +266,7 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi) reg_linkT[] = {'R','E','G','_','L','I','N','K',0}, reg_resource_listT[] = {'R','E','G','_','R','E','S','O','U','R','C','E','_','L','I','S','T',0}, reg_noneT[] = {'R','E','G','_','N','O','N','E',0}, - not_setT[] = {'(','v','a','l','u','e',' ','n','o','t',' ','s','e','t',')',0}, emptyT[] = {0}; - static const TCHAR unknownT[] = {'u','n','k','n','o','w','n','(','%','d',')',0}; plvdi->item.pszText = NULL; plvdi->item.cchTextMax = 0; @@ -304,13 +305,17 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi) plvdi->item.pszText = reg_noneT; break; default: - wsprintf(buffer, unknownT, plvdi->item.lParam); + { + TCHAR szUnknownFmt[64]; + LoadString(hInst, IDS_REGISTRY_UNKNOWN_TYPE, szUnknownFmt, COUNT_OF(szUnknownFmt)); + wsprintf(buffer, szUnknownFmt, plvdi->item.lParam); plvdi->item.pszText = buffer; break; + } } break; case 2: - plvdi->item.pszText = not_setT; + plvdi->item.pszText = g_szValueNotSet; break; case 3: plvdi->item.pszText = emptyT; @@ -459,6 +464,9 @@ HWND CreateListView(HWND hwndParent, int id) RECT rcClient; HWND hwndLV; + /* prepare strings */ + LoadString(hInst, IDS_REGISTRY_VALUE_NOT_SET, g_szValueNotSet, COUNT_OF(g_szValueNotSet)); + /* Get the dimensions of the parent window's client area, and create the list view control. */ GetClientRect(hwndParent, &rcClient); hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"), diff --git a/programs/regedit/main.c b/programs/regedit/main.c index 74c7f07f49e..50939f5067d 100644 --- a/programs/regedit/main.c +++ b/programs/regedit/main.c @@ -29,7 +29,7 @@ #define REGEDIT_DECLARE_FUNCTIONS #include "main.h" -LPCSTR g_pszDefaultValueName = _T("(Default)"); +TCHAR g_pszDefaultValueName[64]; BOOL ProcessCmdLine(LPSTR lpCmdLine); @@ -172,6 +172,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, LoadString(hInstance, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle)); LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, COUNT_OF(szFrameClass)); LoadString(hInstance, IDC_REGEDIT, szChildClass, COUNT_OF(szChildClass)); + LoadString(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, COUNT_OF(g_pszDefaultValueName)); /* Store instance handle in our global variable */ hInst = hInstance; diff --git a/programs/regedit/main.h b/programs/regedit/main.h index 94646066dbf..3d0f129847b 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -90,7 +90,7 @@ extern enum OPTION_FLAGS Options; extern TCHAR szTitle[]; extern TCHAR szFrameClass[]; extern TCHAR szChildClass[]; -extern LPCTSTR g_pszDefaultValueName; +extern TCHAR g_pszDefaultValueName[]; /* about.c */ extern void ShowAboutBox(HWND hWnd); diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h index c062f3aeee4..80a11e7e772 100644 --- a/programs/regedit/resource.h +++ b/programs/regedit/resource.h @@ -47,6 +47,14 @@ #define IDD_FIND 135 #define IDI_BIN 136 #define IDR_POPUP_MENUS 137 +#define IDS_FILEDIALOG_IMPORT_TITLE 144 +#define IDS_FILEDIALOG_EXPORT_TITLE 145 +#define IDS_FILEDIALOG_FILTER 146 +#define IDS_REGISTRY_ROOT_NAME 160 +#define IDS_REGISTRY_DEFAULT_VALUE 161 +#define IDS_REGISTRY_VALUE_NOT_SET 162 +#define IDS_REGISTRY_VALUE_CANT_DISPLAY 164 +#define IDS_REGISTRY_UNKNOWN_TYPE 165 #define IDC_LICENSE_EDIT 1029 #define ID_REGISTRY_EXIT 32770 #define ID_FAVORITES_ADDTOFAVORITES 32772