From 70f7287e587d306092207d79b4402db505776c18 Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 8 Feb 2018 02:57:07 +0100 Subject: [PATCH] More translatable entries for Folder as Workspace --- PowerEditor/installer/nativeLang/chinese.xml | 2 + PowerEditor/installer/nativeLang/english.xml | 19 +++++++ PowerEditor/src/Notepad_plus.cpp | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 9 ---- .../ScitillaComponent/UserDefineDialog.cpp | 21 ++++++-- .../WinControls/FileBrowser/fileBrowser.cpp | 53 ++++++++++++------- .../src/WinControls/FileBrowser/fileBrowser.h | 34 ++++-------- .../FindCharsInRange/FindCharsInRange.cpp | 8 ++- PowerEditor/src/localization.cpp | 34 ++++++++++++ PowerEditor/src/localization.h | 2 +- 10 files changed, 124 insertions(+), 60 deletions(-) diff --git a/PowerEditor/installer/nativeLang/chinese.xml b/PowerEditor/installer/nativeLang/chinese.xml index 0c590d44..16389d8c 100644 --- a/PowerEditor/installer/nativeLang/chinese.xml +++ b/PowerEditor/installer/nativeLang/chinese.xml @@ -91,6 +91,7 @@ + @@ -335,6 +336,7 @@ + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index d09240e0..8e4d139d 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -984,6 +984,10 @@ Are you sure you want to remove this folder from the project?"/> + + + @@ -1007,6 +1011,21 @@ Do you want to continue?"/> + + + + + + + + + + + + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 7e1dce66..adb2a521 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5806,7 +5806,7 @@ void Notepad_plus::launchFileBrowser(const vector & folders) data.dlgID = IDM_VIEW_FILEBROWSER; NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); - generic_string title_temp = pNativeSpeaker->getAttrNameStr(FB_PANELTITLE, "FileBrowser", "PanelTitle"); + generic_string title_temp = pNativeSpeaker->getAttrNameStr(FB_PANELTITLE, "FolderAsWorkspace", "PanelTitle"); static TCHAR title[32]; if (title_temp.length() < 32) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 61934f1b..1fdb834d 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1121,15 +1121,6 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM msg += TEXT("\rfor file type : "); msg += _options._filters[0]?_options._filters:TEXT("*.*"); int res = ::MessageBox(_hParent, msg.c_str(), TEXT("Are you sure?"), MB_OKCANCEL | MB_DEFBUTTON2); - /* - NppParameters::getInstance()->getNativeLangSpeaker()->messageBox("FolderAsWorspaceSubfolderExists", - _hParent, - TEXT("A sub-folder of the folder you want to add exists.\rPlease remove it from the panel before you add folder \"$STR_REPLACE$\"."), - TEXT("Folder as Worspace adding folder problem"), - MB_OK, - 0, // not used - _options._directory.c_str()); - */ if (res == IDOK) { HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 2c1e7c30..ea30976b 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -1049,7 +1049,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR _pUserLang = _pCurrentUserLang; _ctrlTab.init(_hInst, _hSelf, false); - int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(13); + int tabDpiDynamicalHeight = pNppParam->_dpiManager.scaleY(13); _ctrlTab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight); _folderStyleDlg.init(_hInst, _hSelf); @@ -1223,7 +1223,12 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR case IDC_REMOVELANG_BUTTON : { - int result = ::MessageBox(_hSelf, TEXT("Are you sure?"), TEXT("Remove the current language"), MB_YESNO); + int result = pNppParam->getNativeLangSpeaker()->messageBox("UDLRemoveCurrentLang", + _hSelf, + TEXT("Are you sure?"), + TEXT("Remove the current language"), + MB_YESNO); + if (result == IDYES) { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); @@ -1263,7 +1268,11 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR { if (pNppParam->isExistingUserLangName(newName)) { - ::MessageBox(_hSelf, TEXT("This name is used by another language,\rplease give another one."), TEXT("Err"), MB_OK); + pNppParam->getNativeLangSpeaker()->messageBox("UDLNewNameError", + _hSelf, + TEXT("This name is used by another language,\rplease give another one."), + TEXT("UDL Error"), + MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; } @@ -1310,7 +1319,11 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR if (pNppParam->isExistingUserLangName(newName)) { - ::MessageBox(_hSelf, TEXT("This name is used by another language,\rplease give another one."), TEXT("Err"), MB_OK); + pNppParam->getNativeLangSpeaker()->messageBox("UDLNewNameError", + _hSelf, + TEXT("This name is used by another language,\rplease give another one."), + TEXT("UDL Error"), + MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; } diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index f6dcd40c..fe3764dd 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -246,34 +246,46 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP void FileBrowser::initPopupMenus() { + NativeLangSpeaker* pNativeSpeaker = NppParameters::getInstance()->getNativeLangSpeaker(); + + generic_string addRoot = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_ADDROOT, FB_ADDROOT); + generic_string removeAllRoot = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_REMOVEALLROOTS, FB_REMOVEALLROOTS); + generic_string removeRootFolder = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_REMOVEROOTFOLDER, FB_REMOVEROOTFOLDER); + generic_string copyPath = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_COPYEPATH, FB_COPYEPATH); + generic_string findInFile = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_FINDINFILES, FB_FINDINFILES); + generic_string explorerHere = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_EXPLORERHERE, FB_EXPLORERHERE); + generic_string cmdHere = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_CMDHERE, FB_CMDHERE); + generic_string openInNpp = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_OPENINNPP, FB_OPENINNPP); + generic_string shellExecute = pNativeSpeaker->getFileBrowserLangMenuStr(IDM_FILEBROWSER_SHELLEXECUTE, FB_SHELLEXECUTE); + _hGlobalMenu = ::CreatePopupMenu(); - ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDROOT, TEXT("Add")); - ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEALLROOTS, TEXT("Remove All")); + ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDROOT, addRoot.c_str()); + ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEALLROOTS, removeAllRoot.c_str()); _hRootMenu = ::CreatePopupMenu(); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, TEXT("Remove")); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, removeRootFolder.c_str()); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, TEXT("Find in Files...")); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, copyPath.c_str()); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, findInFile.c_str()); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, explorerHere.c_str()); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str()); _hFolderMenu = ::CreatePopupMenu(); - ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); - ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, TEXT("Find in Files...")); + ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, copyPath.c_str()); + ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, findInFile.c_str()); ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); - ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); - ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); + ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, explorerHere.c_str()); + ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str()); _hFileMenu = ::CreatePopupMenu(); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_OPENINNPP, TEXT("Open")); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_OPENINNPP, openInNpp.c_str()); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_SHELLEXECUTE, TEXT("Run by system")); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, copyPath.c_str()); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_SHELLEXECUTE, shellExecute.c_str()); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, explorerHere.c_str()); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str()); } @@ -550,7 +562,6 @@ void FileBrowser::notified(LPNMHDR notification) case TVN_BEGINDRAG: { - //printStr(TEXT("hello")); _treeView.beginDrag((LPNMTREEVIEW)notification); } @@ -723,8 +734,10 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_ADDROOT: { - generic_string folderPath = folderBrowser(_hParent, TEXT("Select a folder to add in Folder as Workspace panel")); - if (not folderPath.empty()) + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + generic_string openWorkspaceStr = pNativeSpeaker->getAttrNameStr(TEXT("Select a folder to add in Folder as Workspace panel"), "FolderAsWorkspace", "SelectFolderFromBrowserString"); + generic_string folderPath = folderBrowser(_hParent, openWorkspaceStr.c_str()); + if (!folderPath.empty()) { addRootFolder(folderPath); } @@ -733,7 +746,7 @@ void FileBrowser::popupMenuCmd(int cmdID) case IDM_FILEBROWSER_SHELLEXECUTE: { - if (not selectedNode) return; + if (!selectedNode) return; generic_string path = getNodePath(selectedNode); if (::PathFileExists(path.c_str())) diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h index e04c6558..e78a4d9a 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.h @@ -37,30 +37,16 @@ #include "TreeView.h" #include "fileBrowser_rc.h" -#define FB_PANELTITLE TEXT("Folder as Workspace") -/* -#define PM_NEWFOLDERNAME TEXT("Folder Name") -#define PM_NEWPROJECTNAME TEXT("Project Name") - -#define PM_SAVEWORKSPACE TEXT("Save") -#define PM_SAVEASWORKSPACE TEXT("Save As...") -#define PM_SAVEACOPYASWORKSPACE TEXT("Save a Copy As...") -#define PM_NEWPROJECTWORKSPACE TEXT("Add New Project") - -#define PM_EDITRENAME TEXT("Rename") -#define PM_EDITNEWFOLDER TEXT("Add Folder") -#define PM_EDITADDFILES TEXT("Add Files...") -#define PM_EDITADDFILESRECUSIVELY TEXT("Add Files from Directory...") -*/ -#define FB_REMOVEROOT TEXT("Remove") - -//#define PM_EDITMODIFYFILE TEXT("Copy path") - -//#define PM_WORKSPACEMENUENTRY TEXT("Workspace") -//#define PM_EDITMENUENTRY TEXT("Edit") - -//#define PM_MOVEUPENTRY TEXT("Move Up\tCtrl+Up") -//#define PM_MOVEDOWNENTRY TEXT("Move Down\tCtrl+Down") +#define FB_PANELTITLE TEXT("Folder as Workspace") +#define FB_ADDROOT TEXT("Add") +#define FB_REMOVEALLROOTS TEXT("Remove All") +#define FB_REMOVEROOTFOLDER TEXT("Remove") +#define FB_COPYEPATH TEXT("Copy path") +#define FB_FINDINFILES TEXT("Find in Files...") +#define FB_EXPLORERHERE TEXT("Explorer here") +#define FB_CMDHERE TEXT("CMD here") +#define FB_OPENINNPP TEXT("Open") +#define FB_SHELLEXECUTE TEXT("Run by system") class TiXmlNode; class FileBrowser; diff --git a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp index f2256125..881a6f7c 100644 --- a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp +++ b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp @@ -28,6 +28,8 @@ #include "FindCharsInRange.h" #include "findCharsInRange_rc.h" +#include "Parameters.h" +#include "localization.h" INT_PTR CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { @@ -60,7 +62,11 @@ INT_PTR CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, L if (!getRangeFromUI(startRange, endRange)) { //STOP! - ::MessageBox(_hSelf, TEXT("You should type between from 0 to 255."), TEXT("Range Value problem"), MB_OK); + NppParameters::getInstance()->getNativeLangSpeaker()->messageBox("FindCharRangeValueError", + _hSelf, + TEXT("You should type between from 0 to 255."), + TEXT("Range Value problem"), + MB_OK); return TRUE; } getDirectionFromUI(direction, isWrap); diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index e0e2978a..512b4bb0 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -1064,6 +1064,40 @@ bool NativeLangSpeaker::getMsgBoxLang(const char *msgBoxTagName, generic_string return false; } +generic_string NativeLangSpeaker::getFileBrowserLangMenuStr(int cmdID, const TCHAR *defaultStr) const +{ + if (!_nativeLangA) return defaultStr; + + TiXmlNodeA *targetNode = _nativeLangA->FirstChild("FolderAsWorkspace"); + if (!targetNode) return defaultStr; + + targetNode = targetNode->FirstChild("Menus"); + if (!targetNode) return defaultStr; + + const char *name = NULL; + for (TiXmlNodeA *childNode = targetNode->FirstChildElement("Item"); + childNode; + childNode = childNode->NextSibling("Item")) + { + TiXmlElementA *element = childNode->ToElement(); + int id; + const char *idStr = element->Attribute("id", &id); + + if (idStr && id == cmdID) + { + name = element->Attribute("name"); + break; + } + } + + if (name && name[0]) + { + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + return wmc->char2wchar(name, _nativeLangEncoding); + } + return defaultStr; +} + generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const { if (!_nativeLangA) return defaultStr; diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index 8f575d4a..f70bc553 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -83,7 +83,7 @@ public: }; bool getMsgBoxLang(const char *msgBoxTagName, generic_string & title, generic_string & message); generic_string getProjectPanelLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const; - //generic_string getFileBrowserLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const; + generic_string getFileBrowserLangMenuStr(int cmdID, const TCHAR *defaultStr) const; generic_string getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name = NULL) const; generic_string getLocalizedStrFromID(const char *strID) const;