From 1a86603a0c42dec8b52af412e7f287cb367d2f30 Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 4 Feb 2018 21:38:49 +0100 Subject: [PATCH] Make more dialog strings translatable --- PowerEditor/installer/nativeLang/english.xml | 43 ++- .../nativeLang/english_customizable.xml | 97 +++++-- PowerEditor/src/Notepad_plus.cpp | 73 +++-- PowerEditor/src/NppBigSwitch.cpp | 4 + PowerEditor/src/NppCommands.cpp | 28 +- PowerEditor/src/NppIO.cpp | 78 +++-- PowerEditor/src/Parameters.cpp | 269 +++++++++--------- PowerEditor/src/ScitillaComponent/Buffer.cpp | 18 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 2 +- PowerEditor/src/ScitillaComponent/Printer.cpp | 3 - PowerEditor/src/WinControls/TabBar/TabBar.cpp | 1 - PowerEditor/src/localization.cpp | 38 --- 12 files changed, 373 insertions(+), 281 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 98898c366..b99313704 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -905,7 +905,7 @@ - + - - + - - - + + + + + + + + + + + + + + + + + + @@ -1020,7 +1049,7 @@ you have to enable "Open all files of folder instead of launching Folder as - <1-to-2-buttons-tip value="2 find buttons mode"/> + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index f7628802c..34006a97e 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -63,7 +63,7 @@ - + @@ -123,10 +123,10 @@ - - - - + + + + @@ -215,7 +215,7 @@ - + @@ -283,7 +283,7 @@ - + @@ -334,7 +334,7 @@ - + @@ -492,7 +492,7 @@ - + @@ -680,7 +680,7 @@ - + @@ -719,7 +719,7 @@ - + @@ -728,9 +728,9 @@ - - - + + + @@ -827,7 +827,7 @@ - + @@ -838,7 +838,7 @@ - + @@ -905,7 +905,7 @@ - + - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -1002,17 +1039,17 @@ Your settings on cloud will be canceled. Please reset a coherent value via Prefe - + - + - + - - - - - <1-to-2-buttons-tip value="2 find buttons mode"/> + + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a9a13d0f3..7e1dce667 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1824,41 +1824,55 @@ void Notepad_plus::filePrint(bool showDialog) int Notepad_plus::doSaveOrNot(const TCHAR *fn) { - TCHAR pattern[64] = TEXT("Save file \"%s\" ?"); - TCHAR phrase[512]; - wsprintf(phrase, pattern, fn); - return doActionOrNot(TEXT("Save"), phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); + return _nativeLangSpeaker.messageBox("DoSaveOrNot", + _pPublicInterface->getHSelf(), + TEXT("Save file \"$STR_REPLACE$\" ?"), + TEXT("Save"), + MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL, + 0, // not used + fn); } int Notepad_plus::doReloadOrNot(const TCHAR *fn, bool dirty) { - TCHAR* pattern = TEXT("%s\r\rThis file has been modified by another program.\rDo you want to reload it%s?"); - TCHAR* lose_info_str = dirty ? TEXT(" and lose the changes made in Notepad++") : TEXT(""); - TCHAR phrase[512]; - wsprintf(phrase, pattern, fn, lose_info_str); - int icon = dirty ? MB_ICONEXCLAMATION : MB_ICONQUESTION; - return doActionOrNot(TEXT("Reload"), phrase, MB_YESNO | MB_APPLMODAL | icon); + if (dirty) + return _nativeLangSpeaker.messageBox("DoReloadOrNotAndLooseChange", + _pPublicInterface->getHSelf(), + TEXT("\"$STR_REPLACE$\"\r\rThis file has been modified by another program.\rDo you want to reload it and lose the changes made in Notepad++?"), + TEXT("Reload"), + MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION, + 0, // not used + fn); + else + return _nativeLangSpeaker.messageBox("DoReloadOrNot", + _pPublicInterface->getHSelf(), + TEXT("\"$STR_REPLACE$\"\r\rThis file has been modified by another program.\rDo you want to reload it?"), + TEXT("Reload"), + MB_YESNO | MB_APPLMODAL | MB_ICONQUESTION, + 0, // not used + fn); } int Notepad_plus::doCloseOrNot(const TCHAR *fn) { - TCHAR pattern[128] = TEXT("The file \"%s\" doesn't exist anymore.\rKeep this file in editor?"); - TCHAR phrase[512]; - wsprintf(phrase, pattern, fn); - return doActionOrNot(TEXT("Keep non existing file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + return _nativeLangSpeaker.messageBox("DoCloseOrNot", + _pPublicInterface->getHSelf(), + TEXT("The file \"$STR_REPLACE$\" doesn't exist anymore.\rKeep this file in editor?"), + TEXT("Keep non existing file"), + MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL, + 0, // not used + fn); } int Notepad_plus::doDeleteOrNot(const TCHAR *fn) { - TCHAR pattern[128] = TEXT("The file \"%s\"\rwill be moved to your Recycle Bin and this document will be closed.\rContinue?"); - TCHAR phrase[512]; - wsprintf(phrase, pattern, fn); - return doActionOrNot(TEXT("Delete file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); -} - -int Notepad_plus::doActionOrNot(const TCHAR *title, const TCHAR *displayText, int type) -{ - return ::MessageBox(_pPublicInterface->getHSelf(), displayText, title, type); + return _nativeLangSpeaker.messageBox("DoDeleteOrNot", + _pPublicInterface->getHSelf(), + TEXT("The file \"$STR_REPLACE$\"\rwill be moved to your Recycle Bin and this document will be closed.\rContinue?"), + TEXT("Delete file"), + MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL, + 0, // not used + fn); } void Notepad_plus::enableMenu(int cmdID, bool doEnable) const @@ -5873,7 +5887,12 @@ void Notepad_plus::launchDocMap() { if (!(NppParameters::getInstance())->isTransparentAvailable()) { - ::MessageBox(NULL, TEXT("It seems you still use a prehistoric system, This feature works only on a modern system, sorry."), TEXT(""), MB_OK); + _nativeLangSpeaker.messageBox("PrehistoricSystemDetected", + _pPublicInterface->getHSelf(), + TEXT("It seems you still use a prehistoric system, This feature works only on a modern system, sorry."), + TEXT("Prehistoric system detected"), + MB_OK); + return; } @@ -5961,10 +5980,6 @@ void Notepad_plus::launchFunctionList() } - - - - struct TextPlayerParams { HWND _nppHandle; @@ -5988,8 +6003,6 @@ struct Quote const char *_quote; }; - - const int nbQuote = 203; Quote quotes[nbQuote] = { diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index f4d95c363..81ff9c2a8 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -693,6 +693,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { if (lstrlen(fileStr) >= int(wParam)) { + // Not message for users so no translation ::MessageBox(hwnd, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM error"), MB_OK); return FALSE; } @@ -714,6 +715,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { if (lstrlen(str) >= int(wParam)) //buffer too small { + // Not message for users so no translation ::MessageBox(hwnd, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETCURRENTWORD error"), MB_OK); return FALSE; } @@ -770,6 +772,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa if (lstrlen(str) >= int(wParam)) //buffer too small { + // Not message for users so no translation ::MessageBox(hwnd, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETFILENAMEATCURSOR error"), MB_OK); return FALSE; } @@ -797,6 +800,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { if (lstrlen(str) >= int(wParam)) { + // Not message for users so no translation ::MessageBox(hwnd, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETNPPDIRECTORY error"), MB_OK); return FALSE; } diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 1f0f2e6f6..49055ed65 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1984,7 +1984,11 @@ void Notepad_plus::command(int id) { if (curBuf->isDirty()) { - ::MessageBox(_pPublicInterface->getHSelf(), TEXT("The document is dirty. Please save the modification before monitoring it."), TEXT("Monitoring problem"), MB_OK); + _nativeLangSpeaker.messageBox("DocTooDirtyToMonitor", + _pPublicInterface->getHSelf(), + TEXT("The document is dirty. Please save the modification before monitoring it."), + TEXT("Monitoring problem"), + MB_OK); } else { @@ -2000,7 +2004,11 @@ void Notepad_plus::command(int id) } else { - ::MessageBox(_pPublicInterface->getHSelf(), TEXT("The file should exist to be monitored."), TEXT("Monitoring problem"), MB_OK); + _nativeLangSpeaker.messageBox("DocNoExistToMonitor", + _pPublicInterface->getHSelf(), + TEXT("The file should exist to be monitored."), + TEXT("Monitoring problem"), + MB_OK); } } @@ -2076,7 +2084,7 @@ void Notepad_plus::command(int id) if (buf->isDirty()) { int answer = _nativeLangSpeaker.messageBox("SaveCurrentModifWarning", - NULL, + _pPublicInterface->getHSelf(), TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"), TEXT("Save Current Modification"), MB_YESNO); @@ -2094,7 +2102,7 @@ void Notepad_plus::command(int id) { generic_string msg, title; int answer = _nativeLangSpeaker.messageBox("LoseUndoAbilityWarning", - NULL, + _pPublicInterface->getHSelf(), TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"), TEXT("Lose Undo Ability Waning"), MB_YESNO); @@ -2191,7 +2199,7 @@ void Notepad_plus::command(int id) { generic_string warning, title; int answer = _nativeLangSpeaker.messageBox("SaveCurrentModifWarning", - NULL, + _pPublicInterface->getHSelf(), TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"), TEXT("Save Current Modification"), MB_YESNO); @@ -2209,7 +2217,7 @@ void Notepad_plus::command(int id) { generic_string msg, title; int answer = _nativeLangSpeaker.messageBox("LoseUndoAbilityWarning", - NULL, + _pPublicInterface->getHSelf(), TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"), TEXT("Lose Undo Ability Waning"), MB_YESNO); @@ -2665,6 +2673,7 @@ void Notepad_plus::command(int id) case IDM_CMDLINEARGUMENTS: { + // No translattable ::MessageBox(NULL, COMMAND_ARG_HELP, TEXT("Notepad++ Command Argument Help"), MB_OK); break; } @@ -2694,7 +2703,12 @@ void Notepad_plus::command(int id) winVer ver = NppParameters::getInstance()->getWinVersion(); if (ver <= WV_XP) { - long res = ::MessageBox(NULL, TEXT("Notepad++ updater is not compatible with XP due to the obsolete security layer under XP.\rDo you want to go to Notepad++ page to download the latest version?"), TEXT("Notepad++ Updater"), MB_YESNO); + long res = _nativeLangSpeaker.messageBox("XpUpdaterProblem", + _pPublicInterface->getHSelf(), + TEXT("Notepad++ updater is not compatible with XP due to the obsolete security layer under XP.\rDo you want to go to Notepad++ page to download the latest version?"), + TEXT("Notepad++ Updater"), + MB_YESNO); + if (res == IDYES) { ::ShellExecute(NULL, TEXT("open"), TEXT("https://notepad-plus-plus.org/download/"), NULL, NULL, SW_SHOWNORMAL); diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index cc5c1c73b..84b8887e8 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -50,13 +50,9 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) //The folder to watch : WCHAR folderToMonitor[MAX_PATH]; - //::MessageBoxW(NULL, mfp->_fullFilePath, TEXT("PATH AFTER thread"), MB_OK); lstrcpy(folderToMonitor, fullFileName); - //MessageBox(NULL, fullFileName, TEXT("fullFileName"), MB_OK); ::PathRemoveFileSpecW(folderToMonitor); - - //MessageBox(NULL, folderToMonitor, TEXT("folderToMonitor"), MB_OK); const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME; @@ -121,7 +117,6 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) // Just for sample purposes. The destructor will // call Terminate() automatically. changes.Terminate(); - //MessageBox(NULL, TEXT("FREEDOM !!!"), TEXT("out"), MB_OK); delete monitorInfo; return EXIT_SUCCESS; } @@ -181,8 +176,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, BufferID test = MainFileManager->getBufferFromName(fileName2Find.c_str()); if (test != BUFFER_INVALID && !isSnapshotMode) { - //switchToFile(test); - //Dont switch, not responsibility of doOpen, but of caller if (_pTrayIco) { if (_pTrayIco->isInTray()) @@ -229,8 +222,15 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, bool isCreateFileSuccessful = false; if (PathFileExists(longFileDir.c_str())) { - wsprintf(str2display, TEXT("%s doesn't exist. Create it?"), longFileName); - if (::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_YESNO) == IDYES) + int res = _nativeLangSpeaker.messageBox("CreateNewFileOrNot", + _pPublicInterface->getHSelf(), + TEXT("\"$INT_REPLACE$\" doesn't exist. Create it?."), + TEXT("Create new file"), + MB_YESNO, + 0, + longFileName); + + if (res == IDYES) { bool res = MainFileManager->createEmptyFile(longFileName); if (res) @@ -239,8 +239,13 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, } else { - wsprintf(str2display, TEXT("Cannot create the file \"%s\""), longFileName); - ::MessageBox(_pPublicInterface->getHSelf(), str2display, TEXT("Create new file"), MB_OK); + _nativeLangSpeaker.messageBox("CreateNewFileError", + _pPublicInterface->getHSelf(), + TEXT("Cannot create the file \"$INT_REPLACE$\"."), + TEXT("Create new file"), + MB_OK, + 0, + longFileName); } } } @@ -389,10 +394,14 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, } else { - generic_string msg = TEXT("Can not open file \""); - msg += longFileName; - msg += TEXT("\"."); - ::MessageBox(_pPublicInterface->getHSelf(), msg.c_str(), TEXT("ERROR"), MB_OK); + _nativeLangSpeaker.messageBox("OpenFileError", + _pPublicInterface->getHSelf(), + TEXT("Can not open file \"$INT_REPLACE$\"."), + TEXT("ERROR"), + MB_OK, + 0, + longFileName); + _isFileOpening = false; scnN.nmhdr.code = NPPN_FILELOADFAILED; @@ -900,10 +909,14 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) if(!activateBuffer(id, SUB_VIEW)) switchEditViewTo(MAIN_VIEW); - TCHAR pattern[140] = TEXT("Your backup file cannot be found (deleted from outside).\rSave it otherwise your data will be lost\rDo you want to save file \"%s\" ?"); - TCHAR phrase[512]; - wsprintf(phrase, pattern, buf->getFullPathName()); - int res = doActionOrNot(TEXT("Save"), phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); + int res = _nativeLangSpeaker.messageBox("NoBackupDoSaveFile", + _pPublicInterface->getHSelf(), + TEXT("Your backup file cannot be found (deleted from outside).\rSave it otherwise your data will be lost\rDo you want to save file \"$STR_REPLACE$\" ?"), + TEXT("Save"), + MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL, + 0, // not used + buf->getFullPathName()); + //int res = doSaveOrNot(buf->getFullPathName()); if (res == IDYES) { @@ -953,11 +966,14 @@ bool Notepad_plus::fileCloseAll(bool doDeleteBackup, bool isSnapshotMode) activateBuffer(id, SUB_VIEW); switchEditViewTo(SUB_VIEW); - TCHAR pattern[140] = TEXT("Your backup file cannot be found (deleted from outside).\rSave it otherwise your data will be lost\rDo you want to save file \"%s\" ?"); - TCHAR phrase[512]; - wsprintf(phrase, pattern, buf->getFullPathName()); - int res = doActionOrNot(TEXT("Save"), phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); - //int res = doSaveOrNot(buf->getFullPathName()); + int res = _nativeLangSpeaker.messageBox("NoBackupDoSaveFile", + _pPublicInterface->getHSelf(), + TEXT("Your backup file cannot be found (deleted from outside).\rSave it otherwise your data will be lost\rDo you want to save file \"$STR_REPLACE$\" ?"), + TEXT("Save"), + MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL, + 0, // not used + buf->getFullPathName()); + if (res == IDYES) { if (!fileSave(id)) @@ -1250,11 +1266,15 @@ bool Notepad_plus::fileSave(BufferID id) if (not ::CopyFile(fn, fn_bak.c_str(), FALSE)) { - generic_string msg = TEXT("The previous version of the file could not be saved into the backup directory at "); - msg += TEXT("\""); - msg += fn_bak; - msg += TEXT("\".\r\rDo you want to save the current file anyways?"); - if (::MessageBox(_pPublicInterface->getHSelf(), msg.c_str(), TEXT("File Backup Failed"), MB_YESNO | MB_ICONERROR) == IDNO) + int res = _nativeLangSpeaker.messageBox("FileBackupFailed", + _pPublicInterface->getHSelf(), + TEXT("The previous version of the file could not be saved into the backup directory at \"$INT_REPLACE$\".\r\rDo you want to save the current file anyways?"), + TEXT("File Backup Failed"), + MB_YESNO | MB_ICONERROR, + 0, + fn_bak.c_str()); + + if (res == IDNO) { return false; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index c2ba20c01..b6fdc9e78 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -509,146 +509,134 @@ static const ScintillaKeyDefinition scintKeyDefs[] = typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); +int strVal(const TCHAR *str, int base) +{ + if (!str) return -1; + if (!str[0]) return 0; - - - - - - - int strVal(const TCHAR *str, int base) - { - if (!str) return -1; - if (!str[0]) return 0; - - TCHAR *finStr; - int result = generic_strtol(str, &finStr, base); - if (*finStr != '\0') - return -1; - return result; - } - - - int decStrVal(const TCHAR *str) - { - return strVal(str, 10); - } - - int hexStrVal(const TCHAR *str) - { - return strVal(str, 16); - } - - int getKwClassFromName(const TCHAR *str) - { - if (!lstrcmp(TEXT("instre1"), str)) return LANG_INDEX_INSTR; - if (!lstrcmp(TEXT("instre2"), str)) return LANG_INDEX_INSTR2; - if (!lstrcmp(TEXT("type1"), str)) return LANG_INDEX_TYPE; - if (!lstrcmp(TEXT("type2"), str)) return LANG_INDEX_TYPE2; - if (!lstrcmp(TEXT("type3"), str)) return LANG_INDEX_TYPE3; - if (!lstrcmp(TEXT("type4"), str)) return LANG_INDEX_TYPE4; - if (!lstrcmp(TEXT("type5"), str)) return LANG_INDEX_TYPE5; - - if ((str[1] == '\0') && (str[0] >= '0') && (str[0] <= '8')) // up to KEYWORDSET_MAX - return str[0] - '0'; - + TCHAR *finStr; + int result = generic_strtol(str, &finStr, base); + if (*finStr != '\0') return -1; - } + return result; +} + + +int decStrVal(const TCHAR *str) +{ + return strVal(str, 10); +} + +int hexStrVal(const TCHAR *str) +{ + return strVal(str, 16); +} + +int getKwClassFromName(const TCHAR *str) +{ + if (!lstrcmp(TEXT("instre1"), str)) return LANG_INDEX_INSTR; + if (!lstrcmp(TEXT("instre2"), str)) return LANG_INDEX_INSTR2; + if (!lstrcmp(TEXT("type1"), str)) return LANG_INDEX_TYPE; + if (!lstrcmp(TEXT("type2"), str)) return LANG_INDEX_TYPE2; + if (!lstrcmp(TEXT("type3"), str)) return LANG_INDEX_TYPE3; + if (!lstrcmp(TEXT("type4"), str)) return LANG_INDEX_TYPE4; + if (!lstrcmp(TEXT("type5"), str)) return LANG_INDEX_TYPE5; + + if ((str[1] == '\0') && (str[0] >= '0') && (str[0] <= '8')) // up to KEYWORDSET_MAX + return str[0] - '0'; + + return -1; +} - size_t getAsciiLenFromBase64Len(size_t base64StrLen) +size_t getAsciiLenFromBase64Len(size_t base64StrLen) +{ + return (base64StrLen % 4) ? 0 : (base64StrLen - base64StrLen / 4); +} + + +int base64ToAscii(char *dest, const char *base64Str) +{ + static const int base64IndexArray[123] = { - return (base64StrLen % 4) ? 0 : (base64StrLen - base64StrLen / 4); - } + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 62, -1, -1, -1, 63, + 52, 53, 54, 55 ,56, 57, 58, 59, + 60, 61, -1, -1, -1, -1, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, -1, -1, -1, -1 ,-1, + -1, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51 + }; + size_t b64StrLen = strlen(base64Str); + size_t nbLoop = b64StrLen / 4; - int base64ToAscii(char *dest, const char *base64Str) + size_t i = 0; + int k = 0; + + enum {b64_just, b64_1padded, b64_2padded} padd = b64_just; + for ( ; i < nbLoop ; i++) { - static const int base64IndexArray[123] = + size_t j = i * 4; + UCHAR uc0, uc1, uc2, uc3, p0, p1; + + uc0 = (UCHAR)base64IndexArray[base64Str[j]]; + uc1 = (UCHAR)base64IndexArray[base64Str[j+1]]; + uc2 = (UCHAR)base64IndexArray[base64Str[j+2]]; + uc3 = (UCHAR)base64IndexArray[base64Str[j+3]]; + + if ((uc0 == -1) || (uc1 == -1) || (uc2 == -1) || (uc3 == -1)) + return -1; + + if (base64Str[j+2] == '=') // && (uc3 == '=') { - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 62, -1, -1, -1, 63, - 52, 53, 54, 55 ,56, 57, 58, 59, - 60, 61, -1, -1, -1, -1, -1, -1, - -1, 0, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, -1, -1, -1, -1 ,-1, - -1, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51 - }; - - size_t b64StrLen = strlen(base64Str); - size_t nbLoop = b64StrLen / 4; - - size_t i = 0; - int k = 0; - - enum {b64_just, b64_1padded, b64_2padded} padd = b64_just; - for ( ; i < nbLoop ; i++) + uc2 = uc3 = 0; + padd = b64_2padded; + } + else if (base64Str[j+3] == '=') { - size_t j = i * 4; - UCHAR uc0, uc1, uc2, uc3, p0, p1; - - uc0 = (UCHAR)base64IndexArray[base64Str[j]]; - uc1 = (UCHAR)base64IndexArray[base64Str[j+1]]; - uc2 = (UCHAR)base64IndexArray[base64Str[j+2]]; - uc3 = (UCHAR)base64IndexArray[base64Str[j+3]]; - - if ((uc0 == -1) || (uc1 == -1) || (uc2 == -1) || (uc3 == -1)) - return -1; - - if (base64Str[j+2] == '=') // && (uc3 == '=') - { - uc2 = uc3 = 0; - padd = b64_2padded; - } - else if (base64Str[j+3] == '=') - { - uc3 = 0; - padd = b64_1padded; - } - - p0 = uc0 << 2; - p1 = uc1 << 2; - p1 >>= 6; - dest[k++] = p0 | p1; - - p0 = uc1 << 4; - p1 = uc2 << 2; - p1 >>= 4; - dest[k++] = p0 | p1; - - p0 = uc2 << 6; - p1 = uc3; - dest[k++] = p0 | p1; + uc3 = 0; + padd = b64_1padded; } - //dest[k] = '\0'; - if (padd == b64_1padded) - // dest[k-1] = '\0'; - return k-1; - else if (padd == b64_2padded) - // dest[k-2] = '\0'; - return k-2; + p0 = uc0 << 2; + p1 = uc1 << 2; + p1 >>= 6; + dest[k++] = p0 | p1; - return k; + p0 = uc1 << 4; + p1 = uc2 << 2; + p1 >>= 4; + dest[k++] = p0 | p1; + + p0 = uc2 << 6; + p1 = uc3; + dest[k++] = p0 | p1; } + //dest[k] = '\0'; + if (padd == b64_1padded) + // dest[k-1] = '\0'; + return k-1; + else if (padd == b64_2padded) + // dest[k-2] = '\0'; + return k-2; + + return k; +} + } // anonymous namespace - - - - - void cutString(const TCHAR* str2cut, vector& patternVect) { if (str2cut == nullptr) return; @@ -891,16 +879,25 @@ NppParameters::~NppParameters() } -bool NppParameters::reloadStylers(TCHAR *stylePath) +bool NppParameters::reloadStylers(TCHAR* stylePath) { if (_pXmlUserStylerDoc) delete _pXmlUserStylerDoc; - _pXmlUserStylerDoc = new TiXmlDocument(stylePath?stylePath:_stylerPath); + const TCHAR* stylePathToLoad = stylePath != nullptr ? stylePath : _stylerPath.c_str(); + _pXmlUserStylerDoc = new TiXmlDocument(stylePathToLoad); + bool loadOkay = _pXmlUserStylerDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, TEXT("Load stylers.xml failed!"), stylePath, MB_OK); + _pNativeLangSpeaker->messageBox("LoadStylersFailed", + NULL, + TEXT("Load \"$INT_REPLACE$\" failed!"), + TEXT("Load stylers.xml failed"), + MB_OK, + 0, + stylePathToLoad); + delete _pXmlUserStylerDoc; _pXmlUserStylerDoc = NULL; return false; @@ -1083,7 +1080,11 @@ bool NppParameters::load() if (generic_stat(langs_xml_path.c_str(), &buf)==0) if (buf.st_size == 0) - doRecover = ::MessageBox(NULL, TEXT("Load langs.xml failed!\rDo you want to recover your langs.xml?"), TEXT("Configurator"),MB_YESNO); + doRecover = _pNativeLangSpeaker->messageBox("LoadLangsFailed", + NULL, + TEXT("Load langs.xml failed!\rDo you want to recover your langs.xml?"), + TEXT("Configurator"), + MB_YESNO); } else doRecover = true; @@ -1101,7 +1102,12 @@ bool NppParameters::load() bool loadOkay = _pXmlDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, TEXT("Load langs.xml failed!"), TEXT("Configurator"),MB_OK); + _pNativeLangSpeaker->messageBox("LoadLangsFailedFinal", + NULL, + TEXT("Load langs.xml failed!"), + TEXT("Configurator"), + MB_OK); + delete _pXmlDoc; _pXmlDoc = nullptr; isAllLaoded = false; @@ -1157,7 +1163,14 @@ bool NppParameters::load() loadOkay = _pXmlUserStylerDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, TEXT("Load stylers.xml failed!"), _stylerPath.c_str(), MB_OK); + _pNativeLangSpeaker->messageBox("LoadStylersFailed", + NULL, + TEXT("Load \"$INT_REPLACE$\" failed!"), + TEXT("Load stylers.xml failed"), + MB_OK, + 0, + _stylerPath.c_str()); + delete _pXmlUserStylerDoc; _pXmlUserStylerDoc = NULL; isAllLaoded = false; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 70d1b2cd3..41fae56b0 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -1337,14 +1337,13 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, // As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space) if (bufferSizeRequested > INT_MAX) { - ::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File size problem"), MB_OK|MB_APPLMODAL); - /* - _nativeLangSpeaker.messageBox("NbFileToOpenImportantWarning", - _pPublicInterface->getHSelf(), + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + pNativeSpeaker->messageBox("FileTooBigToOpene", + NULL, TEXT("File is too big to be opened by Notepad++"), - TEXT("File open problem"), + TEXT("File size problem"), MB_OK|MB_APPLMODAL); - */ + fclose(fp); return false; } @@ -1459,7 +1458,12 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, } __except(EXCEPTION_EXECUTE_HANDLER) //TODO: should filter correctly for other exceptions; the old filter(GetExceptionCode(), GetExceptionInformation()) was only catching access violations { - ::MessageBox(NULL, TEXT("File is too big to be opened by Notepad++"), TEXT("File open problem"), MB_OK|MB_APPLMODAL); + NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); + pNativeSpeaker->messageBox("FileTooBigToOpene", + NULL, + TEXT("File is too big to be opened by Notepad++"), + TEXT("File size problem"), + MB_OK | MB_APPLMODAL); success = false; } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 92ac59233..8daaba0fe 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -815,7 +815,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM SendMessage(_shiftTrickUpTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((15000), (0))); } - generic_string checkboxTip = pNativeSpeaker->getLocalizedStrFromID("1-to-2-buttons-tip"); + generic_string checkboxTip = pNativeSpeaker->getLocalizedStrFromID("two-find-buttons-tip"); if (checkboxTip.empty()) checkboxTip = TEXT("2 find buttons mode"); diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index f663b2054..72cbc2744 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -149,8 +149,6 @@ size_t Printer::doPrint(bool justDoIt) const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial"); int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); - //TCHAR toto[10]; - //::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), TEXT("header"), MB_OK); HFONT fontHeader = ::CreateFont(headerLineHeight, 0, 0, 0, @@ -169,7 +167,6 @@ size_t Printer::doPrint(bool justDoIt) fontWeight = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL); isFontItalic = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_ITALIC?TRUE:FALSE); fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial"); - //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK); int footerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); HFONT fontFooter = ::CreateFont(footerLineHeight, diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 4bcecd6f3..eb06afd34 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -859,7 +859,6 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) if (nTab < 0) { ::MessageBox(NULL, TEXT("nTab < 0"), TEXT(""), MB_OK); - //return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); } bool isSelected = (nTab == ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 8ee0a1bdc..e0e2978aa 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -1100,44 +1100,6 @@ generic_string NativeLangSpeaker::getProjectPanelLangMenuStr(const char * nodeNa } return defaultStr; } -/* -generic_string NativeLangSpeaker::getFileBrowserLangMenuStr(const char * nodeName, int cmdID, const TCHAR *defaultStr) const -{ - if (!_nativeLangA) return defaultStr; - - TiXmlNodeA *targetNode = _nativeLangA->FirstChild("FileBrowser"); - if (!targetNode) return defaultStr; - - targetNode = targetNode->FirstChild("Menus"); - if (!targetNode) return defaultStr; - - targetNode = targetNode->FirstChild(nodeName); - 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::getAttrNameStr(const TCHAR *defaultStr, const char *nodeL1Name, const char *nodeL2Name) const {