From 6bc7abb02148a4dd77f535a34c33b65a7fdb9ad1 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 31 Mar 2025 17:23:24 +0200 Subject: [PATCH] Make some items translatable (in UDL & on status bar) Fix #15426, fix #8004, fix #8972, close #16347 --- PowerEditor/installer/nativeLang/english.xml | 17 +++++ .../nativeLang/english_customizable.xml | 17 +++++ PowerEditor/installer/nativeLang/french.xml | 19 +++++- .../nativeLang/taiwaneseMandarin.xml | 17 +++++ .../MISC/PluginsManager/PluginsManager.cpp | 28 -------- .../src/MISC/PluginsManager/PluginsManager.h | 2 - PowerEditor/src/Notepad_plus.cpp | 65 ++++++++++--------- .../ScintillaComponent/UserDefineDialog.cpp | 40 ++++++++++-- 8 files changed, 140 insertions(+), 65 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 6ce23f061..8aa647a9b 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1522,6 +1522,11 @@ Do you want to continue?"/> + + + + + C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON. If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/> + + + + + + + + + + + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 92fdedc0a..c6d630d42 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1522,6 +1522,11 @@ Do you want to continue?"/> + + + + + C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON. If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/> + + + + + + + + + + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index d4e739a9b..256e302eb 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1521,7 +1521,12 @@ Il semble que le fichier à ouvrir n’appartient pas au projet."/> Voulez-vous continuer ?"/> - + + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 89f69c649..df128b382 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1415,6 +1415,11 @@ + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index d4d88c3b5..12c50ffa9 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -30,34 +30,6 @@ using namespace std; const wchar_t * USERMSG = L" is not compatible with the current version of Notepad++.\n\n\ Do you want to remove this plugin from the plugins directory to prevent this message from the next launch?"; - -bool PluginsManager::unloadPlugin(int index, HWND nppHandle) -{ - SCNotification scnN; - scnN.nmhdr.code = NPPN_SHUTDOWN; - scnN.nmhdr.hwndFrom = nppHandle; - scnN.nmhdr.idFrom = 0; - _pluginInfos[index]->_pBeNotified(&scnN); - - //::DestroyMenu(_pluginInfos[index]->_pluginMenu); - //_pluginInfos[index]->_pluginMenu = NULL; - - if (::FreeLibrary(_pluginInfos[index]->_hLib)) - { - _pluginInfos[index]->_hLib = nullptr; - printStr(L"we're good"); - } - else - printStr(L"not ok"); - - //delete _pluginInfos[index]; -// printInt(index); - //vector::iterator it = _pluginInfos.begin() + index; - //_pluginInfos.erase(it); - //printStr(L"remove"); - return true; -} - static WORD getBinaryArchitectureType(const wchar_t *filePath) { HANDLE hFile = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 23fdf19bb..0a5ad4db7 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -94,8 +94,6 @@ public: bool loadPlugins(const wchar_t *dir = NULL, const PluginViewList* pluginUpdateInfoList = nullptr, PluginViewList* pluginImcompatibleList = nullptr); - bool unloadPlugin(int index, HWND nppHandle); - void runPluginCommand(size_t i); void runPluginCommand(const wchar_t *pluginName, int commandID); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 7606cd484..41733bc69 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4326,15 +4326,20 @@ void Notepad_plus::updateStatusBar() // these sections of status bar NOT updated by this function: // STATUSBAR_DOC_TYPE , STATUSBAR_EOF_FORMAT , STATUSBAR_UNICODE_TYPE - wchar_t strDocLen[256]; size_t docLen = _pEditView->getCurrentDocLen(); intptr_t nbLine = _pEditView->execute(SCI_GETLINECOUNT); - wsprintf(strDocLen, L"length : %s lines : %s", - commafyInt(docLen).c_str(), - commafyInt(nbLine).c_str()); - _statusBar.setText(strDocLen, STATUSBAR_DOC_SIZE); - wchar_t strSel[64]; + wstring docLenStr = commafyInt(docLen); + wstring nbLineStr = commafyInt(nbLine); + + NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); + wstring statusbarLengthLinesStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-length-lines", L"length: $STR_REPLACE1$ lines: $STR_REPLACE2$"); + statusbarLengthLinesStr = stringReplace(statusbarLengthLinesStr, L"$STR_REPLACE1$", docLenStr); + statusbarLengthLinesStr = stringReplace(statusbarLengthLinesStr, L"$STR_REPLACE2$", nbLineStr); + + _statusBar.setText(statusbarLengthLinesStr.c_str(), STATUSBAR_DOC_SIZE); + + wstring statusbarSelStr; size_t nbSelections = _pEditView->execute(SCI_GETSELECTIONS); if (nbSelections == 1) @@ -4342,14 +4347,14 @@ void Notepad_plus::updateStatusBar() if (_pEditView->execute(SCI_GETSELECTIONEMPTY)) { size_t currPos = _pEditView->execute(SCI_GETCURRENTPOS); - wsprintf(strSel, L"Pos : %s", commafyInt(currPos + 1).c_str()); + statusbarSelStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-Pos", L"Pos: "); + statusbarSelStr += commafyInt(currPos + 1); } else { const std::pair oneSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount(); - wsprintf(strSel, L"Sel : %s | %s", - commafyInt(oneSelCharsAndLines.first).c_str(), - commafyInt(oneSelCharsAndLines.second).c_str()); + statusbarSelStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-Sel", L"Sel: "); + statusbarSelStr += commafyInt(oneSelCharsAndLines.first) + L" | " + commafyInt(oneSelCharsAndLines.second); } } else if (_pEditView->execute(SCI_SELECTIONISRECTANGLE)) @@ -4382,33 +4387,35 @@ void Notepad_plus::updateStatusBar() } } - wsprintf(strSel, L"Sel : %sx%s %s %s", - commafyInt(nbSelections).c_str(), // lines (rows) in rectangular selection - commafyInt(maxLineCharCount).c_str(), // show maximum width for columns - sameCharCountOnEveryLine ? L"=" : L"->", - commafyInt(rectSelCharsAndLines.first).c_str()); + wstring nbSelectionsStr = commafyInt(nbSelections); // lines (rows) in rectangular selection + wstring maxLineCharCountStr = commafyInt(maxLineCharCount); // show maximum width for columns + wstring opStr = sameCharCountOnEveryLine ? L" = " : L" -> "; + wstring rectSelCharsStr = commafyInt(rectSelCharsAndLines.first); + + statusbarSelStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-Sel", L"Sel: "); + statusbarSelStr += nbSelectionsStr + L"x" + maxLineCharCountStr + opStr + rectSelCharsStr; } else // multiple stream selections { const int maxSelsToProcessLineCount = 99; // limit the number of selections to process, for performance reasons const std::pair multipleSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount(maxSelsToProcessLineCount); - wsprintf(strSel, L"Sel %s : %s | %s", - commafyInt(nbSelections).c_str(), - commafyInt(multipleSelCharsAndLines.first).c_str(), - nbSelections <= maxSelsToProcessLineCount ? - commafyInt(multipleSelCharsAndLines.second).c_str() : - L"..."); // show ellipsis for line count if too many selections are active + wstring nbSelectionsStr = commafyInt(nbSelections); + wstring multipleSelChars = commafyInt(multipleSelCharsAndLines.first); + wstring multipleSelLines = (nbSelections <= maxSelsToProcessLineCount) ? commafyInt(multipleSelCharsAndLines.second) : L"..."; // show ellipsis for line count if too many selections are active + + statusbarSelStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-Sel-number", L"Sel"); + statusbarSelStr += L" " + nbSelectionsStr + L" : " + multipleSelChars + L" | " + multipleSelLines; } - wchar_t strLnColSel[128]; - intptr_t curLN = _pEditView->getCurrentLineNumber(); - intptr_t curCN = _pEditView->getCurrentColumnNumber(); - wsprintf(strLnColSel, L"Ln : %s Col : %s %s", - commafyInt(curLN + 1).c_str(), - commafyInt(curCN + 1).c_str(), - strSel); - _statusBar.setText(strLnColSel, STATUSBAR_CUR_POS); + wstring lnStr = commafyInt(_pEditView->getCurrentLineNumber() + 1); + wstring colStr = commafyInt(_pEditView->getCurrentColumnNumber() + 1); + wstring statusbarLnColStr = pNativeSpeaker->getLocalizedStrFromID("statusbar-Ln-Col", L"Ln: $STR_REPLACE1$ Col: $STR_REPLACE2$"); + statusbarLnColStr = stringReplace(statusbarLnColStr, L"$STR_REPLACE1$", lnStr); + statusbarLnColStr = stringReplace(statusbarLnColStr, L"$STR_REPLACE2$", colStr); + wstring statusbarLnColSelStr = statusbarLnColStr + L" " + statusbarSelStr; + + _statusBar.setText(statusbarLnColSelStr.c_str(), STATUSBAR_CUR_POS); _statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? L"OVR" : L"INS", STATUSBAR_TYPING_MODE); diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp index 74c20e98a..abd2fed26 100644 --- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp @@ -1397,28 +1397,48 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA wstring sourceFile = fDlg.doOpenSingleFileDlg(); if (sourceFile.empty()) break; + NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker(); + bool isSuccessful = nppParam.importUDLFromFile(sourceFile); if (isSuccessful) { auto i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); reloadLangCombo(); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_SETCURSEL, i, 0); - printStr(L"Import successful."); + + pNativeSpeaker->messageBox("UDL_importSuccessful", + _hSelf, + L"Import successful.", + L"User Defined Language", + MB_OK | MB_APPLMODAL, + 0); } else { - printStr(L"Fail to import."); + pNativeSpeaker->messageBox("UDL_importFails", + _hSelf, + L"Failed to import.", + L"User Defined Language", + MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION, + 0); } break; } case IDC_EXPORT_BUTTON : { + NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker(); + auto i2Export = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); if (i2Export == 0) { // maybe a better option would be to simply send IDC_SAVEAS_BUTTON message, and display "Save As..." dialog? - printStr(L"Before exporting, save your language definition by clicking \"Save As...\" button"); + pNativeSpeaker->messageBox("UDL_saveBeforeImport", + _hSelf, + L"Before exporting, save your language definition by clicking \"Save As...\" button", + L"User Defined Language", + MB_OK | MB_APPLMODAL, + 0); break; } @@ -1433,11 +1453,21 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA bool isSuccessful = nppParam.exportUDLToFile(i2Export - 1, fileName2save); if (isSuccessful) { - printStr(L"Export successful"); + pNativeSpeaker->messageBox("UDL_exportSuccessful", + _hSelf, + L"Export successful.", + L"User Defined Language", + MB_OK | MB_APPLMODAL, + 0); } else { - printStr(L"Fail to export."); + pNativeSpeaker->messageBox("UDL_exportFails", + _hSelf, + L"Failed to export.", + L"User Defined Language", + MB_OK | MB_APPLMODAL | MB_ICONEXCLAMATION, + 0); } } break;