Fix "Save a Copy As" dialog's wrong title

1. Use appropriated localized title on some main save/open dialogs.
2. Reuse menu localized string and remove some redundent entries from localization files.

Fix #14737, fix #11860, close #14808
pull/14810/head
Don Ho 2024-02-27 18:22:05 +01:00
parent 12548b6abb
commit 13cd4acad6
13 changed files with 86 additions and 36 deletions

View File

@ -1644,7 +1644,6 @@ NOTE: Choosing not to create the placeholders or closing them later, your sessio
<default-open-save-select-folder value="Select a folder as default directory"/><!-- HowToReproduce: Settings > Preferences > Default Directory > [...] -->
<shift-change-direction-tip value="Use Shift+Enter to search in the opposite direction"/>
<two-find-buttons-tip value="2 find buttons mode"/>
<file-rename-title value="Rename"/>
<find-in-files-filter-tip value="Find in cpp, cxx, h, hxx &amp;&amp; hpp:
*.cpp *.cxx *.h *.hxx *.hpp
@ -1690,9 +1689,7 @@ Find in all files but exclude all folders log or logs recursively:
<finder-collapse-all value="Fold all"/>
<finder-uncollapse-all value="Unfold all"/>
<finder-copy value="Copy Selected Line(s)"/>
<finder-copy-verbatim value="Copy"/>
<finder-copy-paths value="Copy Pathname(s)"/>
<finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/>
<finder-purge-for-every-search value="Purge for every search"/>
@ -1719,7 +1716,6 @@ Find in all files but exclude all folders log or logs recursively:
<summary-nbsel2 value=" bytes) in "/>
<summary-nbrange value=" ranges"/>
<progress-hits-title value="Hits:"/>
<progress-cancel-button value="Cancel"/>
<progress-cancel-info value="Cancelling operation, please wait..."/>
<find-in-files-progress-title value="Find In Files progress..."/>
<replace-in-files-confirm-title value="Are you sure?"/>

View File

@ -1643,7 +1643,6 @@ NOTE: Choosing not to create the placeholders or closing them later, your sessio
<default-open-save-select-folder value="Select a folder as default directory"/><!-- HowToReproduce: Settings > Preferences > Default Directory > [...] -->
<shift-change-direction-tip value="Use Shift+Enter to search in the opposite direction"/>
<two-find-buttons-tip value="2 find buttons mode"/>
<file-rename-title value="Rename"/>
<find-in-files-filter-tip value="Find in cpp, cxx, h, hxx &amp;&amp; hpp:
*.cpp *.cxx *.h *.hxx *.hpp
@ -1689,9 +1688,7 @@ Find in all files but exclude all folders log or logs recursively:
<finder-collapse-all value="Fold all"/>
<finder-uncollapse-all value="Unfold all"/>
<finder-copy value="Copy Selected Line(s)"/>
<finder-copy-verbatim value="Copy"/>
<finder-copy-paths value="Copy Pathname(s)"/>
<finder-select-all value="Select all"/>
<finder-clear-all value="Clear all"/>
<finder-open-all value="Open all"/>
<finder-purge-for-every-search value="Purge for every search"/>
@ -1718,7 +1715,6 @@ Find in all files but exclude all folders log or logs recursively:
<summary-nbsel2 value=" bytes) in "/>
<summary-nbrange value=" ranges"/>
<progress-hits-title value="Hits:"/>
<progress-cancel-button value="Cancel"/>
<progress-cancel-info value="Cancelling operation, please wait..."/>
<find-in-files-progress-title value="Find In Files progress..."/>
<replace-in-files-confirm-title value="Are you sure?"/>

View File

@ -1640,7 +1640,6 @@ NOTE : Si vous choisissez de ne pas créer d'espaces réservés ou de les fermer
<default-open-save-select-folder value="Sélectionner un dossier pour le répertoire par défaut"/><!-- HowToReproduce: Settings > Preferences > Default Directory > [...] -->
<shift-change-direction-tip value="Utilisez Maj + Entrée pour rechercher dans le sens inverse"/>
<two-find-buttons-tip value="2 boutons Recherche"/>
<file-rename-title value="Renommer"/>
<find-in-files-filter-tip value="Rechercher dans cpp, cxx, h, hxx &amp;&amp; hpp:
*.cpp *.cxx *.h *.hxx *.hpp
@ -1686,9 +1685,7 @@ Rechercher dans tous les fichiers mais pas dans les dossiers log ou logs récurs
<finder-collapse-all value="Replier tout"/>
<finder-uncollapse-all value="Déplier tout"/>
<finder-copy value="Copier la(les) ligne(s) sélectionnée(s)"/>
<finder-copy-verbatim value="Copier"/>
<finder-copy-paths value="Copier le(s) chemin(s)"/>
<finder-select-all value="Sélectionner tout"/>
<finder-clear-all value="Effacer tout"/>
<finder-open-all value="Ouvrir tout"/>
<finder-purge-for-every-search value="Purger chaque recherche"/>
@ -1715,7 +1712,6 @@ Rechercher dans tous les fichiers mais pas dans les dossiers log ou logs récurs
<summary-nbsel2 value=" octets) dans "/>
<summary-nbrange value=" sélections"/>
<progress-hits-title value="Résultats :"/>
<progress-cancel-button value="Annuler"/>
<progress-cancel-info value="Annulation de l'opération, veuillez patienter..."/>
<find-in-files-progress-title value="Rechercher dans les fichiers en cours..."/>
<replace-in-files-confirm-title value="Confirmation"/>

View File

@ -1560,8 +1560,6 @@
<finder-collapse-all value="層數全部收折"/>
<finder-uncollapse-all value="層數全部展開"/>
<finder-copy value="複製全行"/>
<finder-copy-verbatim value="複製"/>
<finder-select-all value="全部選取"/>
<finder-clear-all value="全部清除"/>
<finder-open-all value="全部開啟"/>
<finder-wrap-long-lines value="自動換行"/>

View File

@ -7357,8 +7357,9 @@ void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders, con
NativeLangSpeaker *pNativeSpeaker = nppParams.getNativeLangSpeaker();
generic_string title_temp = pNativeSpeaker->getAttrNameStr(FB_PANELTITLE, FOLDERASWORKSPACE_NODE, "PanelTitle");
static TCHAR title[32];
if (title_temp.length() < 32)
const int titleLen = 64;
static TCHAR title[titleLen];
if (title_temp.length() < titleLen)
{
wcscpy_s(title, title_temp.c_str());
data.pszName = title;
@ -7645,6 +7646,7 @@ static const QuoteParams quotes[] =
{TEXT("Darth Vader #2"), QuoteParams::rapid, true, SC_CP_UTF8, L_TEXT, TEXT("You don't get to 500 million star systems without making a few enemies.")},
{TEXT("Doug Linder"), QuoteParams::rapid, true, SC_CP_UTF8, L_TEXT, TEXT("A good programmer is someone who always looks both ways before crossing a one-way street.")},
{TEXT("Jean-Claude van Damme"), QuoteParams::rapid, true, SC_CP_UTF8, L_TEXT, TEXT("A cookie has no soul, it's just a cookie. But before it was milk and eggs.\nAnd in eggs there's the potential for life.")},
{TEXT("Mark Zuckerberg"), QuoteParams::slow, false, SC_CP_UTF8, L_TEXT, TEXT("\"Black lives matter\" doesn't mean other lives don't - it's simply asking that the black community also achieves the justice they deserve.")},
{TEXT("Michael Feldman"), QuoteParams::slow, false, SC_CP_UTF8, L_TEXT, TEXT("Java is, in many ways, C++--.")},
{TEXT("Don Ho"), QuoteParams::slow, false, SC_CP_UTF8, L_TEXT, TEXT("Je mange donc je chie.")},
{TEXT("Don Ho #2"), QuoteParams::rapid, true, SC_CP_UTF8, L_TEXT, TEXT("RTFM is the true path of every developer.\nBut it would happen only if there's no way out.")},

View File

@ -1186,7 +1186,7 @@ BEGIN
POPUP "Import"
BEGIN
MENUITEM "Import plugin(s)...", IDM_SETTING_IMPORTPLUGIN
MENUITEM "Import style theme(s)...", IDM_SETTING_IMPORTSTYLETHEMS
MENUITEM "Import style theme(s)...", IDM_SETTING_IMPORTSTYLETHEMES
END
MENUITEM SEPARATOR
MENUITEM "Edit Popup ContextMenu", IDM_SETTING_EDITCONTEXTMENU

View File

@ -3181,7 +3181,7 @@ void Notepad_plus::command(int id)
break;
}
case IDM_SETTING_IMPORTSTYLETHEMS :
case IDM_SETTING_IMPORTSTYLETHEMES :
{
// get plugin source path
const TCHAR *extFilterName = TEXT("Notepad++ style theme");

View File

@ -1792,6 +1792,17 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy)
fDlg.setExtIndex(langTypeIndex + 1); // +1 for "All types"
generic_string localizedTitle;
if (isSaveCopy)
{
localizedTitle = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_SAVECOPYAS, L"Save a Copy As", true);
}
else
{
localizedTitle = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_SAVEAS, L"Save As", true);
}
fDlg.setTitle(localizedTitle.c_str());
const generic_string checkboxLabel = _nativeLangSpeaker.getLocalizedStrFromID("file-save-assign-type",
TEXT("&Append extension"));
fDlg.enableFileTypeCheckbox(checkboxLabel, !defaultAllTypes);
@ -1875,8 +1886,8 @@ bool Notepad_plus::fileRename(BufferID id)
fDlg.setFolder(buf->getFullPathName());
fDlg.setDefFileName(buf->getFileName());
std::wstring title = _nativeLangSpeaker.getLocalizedStrFromID("file-rename-title", L"Rename");
fDlg.setTitle(title.c_str());
wstring localizedRename = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_RENAME, L"Rename", true);
fDlg.setTitle(localizedRename.c_str());
std::wstring fn = fDlg.doSaveDlg();
@ -2011,6 +2022,8 @@ bool Notepad_plus::fileDelete(BufferID id)
void Notepad_plus::fileOpen()
{
CustomFileDialog fDlg(_pPublicInterface->getHSelf());
wstring localizedTitle = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_OPEN, L"Open", true);
fDlg.setTitle(localizedTitle.c_str());
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"));
setFileOpenSaveDlgFilters(fDlg, true);
@ -2460,6 +2473,8 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn)
fDlg.setDefExt(ext);
}
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"));
wstring localizedTitle = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_LOADSESSION, L"Load Session", true);
fDlg.setTitle(localizedTitle.c_str());
sessionFileName = fDlg.doOpenSingleFileDlg();
}
else
@ -2558,9 +2573,10 @@ const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames)
}
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"));
const bool isCheckboxActive = _pFileBrowser && !_pFileBrowser->isClosed();
const generic_string checkboxLabel = _nativeLangSpeaker.getLocalizedStrFromID("session-save-folder-as-workspace",
TEXT("Save Folder as Workspace"));
const generic_string checkboxLabel = _nativeLangSpeaker.getLocalizedStrFromID("session-save-folder-as-workspace", L"Save Folder as Workspace");
fDlg.setCheckbox(checkboxLabel.c_str(), isCheckboxActive);
wstring localizedTitle = _nativeLangSpeaker.getNativeLangMenuString(IDM_FILE_SAVESESSION, L"Save Session", true);
fDlg.setTitle(localizedTitle.c_str());
generic_string sessionFileName = fDlg.doSaveDlg();
if (!sessionFileName.empty())

View File

@ -417,7 +417,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_NULL, IDM_LANGSTYLE_CONFIG_DLG, false, false, false, nullptr },
{ VK_NULL, IDM_SETTING_SHORTCUT_MAPPER, false, false, false, nullptr },
{ VK_NULL, IDM_SETTING_IMPORTPLUGIN, false, false, false, nullptr },
{ VK_NULL, IDM_SETTING_IMPORTSTYLETHEMS, false, false, false, nullptr },
{ VK_NULL, IDM_SETTING_IMPORTSTYLETHEMES, false, false, false, nullptr },
{ VK_NULL, IDM_SETTING_EDITCONTEXTMENU, false, false, false, nullptr },
{ VK_R, IDC_EDIT_TOGGLEMACRORECORDING, true, false, true, TEXT("Toggle macro recording")},

View File

@ -5258,10 +5258,10 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
generic_string collapseAll = pNativeSpeaker->getLocalizedStrFromID("finder-collapse-all", TEXT("Fold all"));
generic_string uncollapseAll = pNativeSpeaker->getLocalizedStrFromID("finder-uncollapse-all", TEXT("Unfold all"));
generic_string copyLines = pNativeSpeaker->getLocalizedStrFromID("finder-copy", TEXT("Copy Selected Line(s)"));
generic_string copyVerbatim = pNativeSpeaker->getLocalizedStrFromID("finder-copy-verbatim", TEXT("Copy"));
generic_string copyVerbatim = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_COPY, L"Rename", true);
copyVerbatim += TEXT("\tCtrl+C");
generic_string copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-paths", TEXT("Copy Pathname(s)"));
generic_string selectAll = pNativeSpeaker->getLocalizedStrFromID("finder-select-all", TEXT("Select all"));
generic_string selectAll = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_SELECTALL, L"Select all", true);
selectAll += TEXT("\tCtrl+A");
generic_string clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", TEXT("Clear all"));
generic_string purgeForEverySearch = pNativeSpeaker->getLocalizedStrFromID("finder-purge-for-every-search", TEXT("Purge for every search"));
@ -5897,7 +5897,7 @@ int Progress::createProgressWindow()
::SendMessage(_hPBar, PBM_SETBARCOLOR, 0, static_cast<LPARAM>(NppDarkMode::getDarkerTextColor()));
}
generic_string cancel = pNativeSpeaker->getLocalizedStrFromID("progress-cancel-button", TEXT("Cancel"));
generic_string cancel = pNativeSpeaker->getLocalizedStrFromID("common-cancel", TEXT("Cancel"));
_hBtn = ::CreateWindowEx(0, TEXT("BUTTON"), cancel.c_str(),
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | BS_TEXT,

View File

@ -198,19 +198,59 @@ generic_string NativeLangSpeaker::getSubMenuEntryName(const char *nodeName) cons
return TEXT("");
}
generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID) const
void purifyMenuString(string& s)
{
// Remove & for CJK localization
size_t posAndCJK = s.find("(&", 0);
if (posAndCJK != string::npos)
{
if (posAndCJK + 3 < s.length())
{
if (s[posAndCJK + 3] == ')')
s.erase(posAndCJK, 4);
}
}
// Remove & and transform && to & for all localizations
for (int i = static_cast<int>(s.length()) - 1; i >= 0; --i)
{
if (s[i] == '&')
{
if (i-1 >= 0 && s[i-1] == '&')
{
s.erase(i, 1);
i -= 1;
}
else
{
s.erase(i, 1);
}
}
}
// Remove ellipsis...
size_t len = s.length();
if (len <= 3)
return;
size_t posEllipsis = len - 3;
if (s.substr(posEllipsis) == "...")
s.erase(posEllipsis, 3);
}
generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID, generic_string inCaseOfFailureStr, bool removeMarkAnd) const
{
if (!_nativeLangA)
return TEXT("");
return inCaseOfFailureStr;
TiXmlNodeA *node = _nativeLangA->FirstChild("Menu");
if (!node) return TEXT("");
if (!node) return inCaseOfFailureStr;
node = node->FirstChild("Main");
if (!node) return TEXT("");
if (!node) return inCaseOfFailureStr;
node = node->FirstChild("Commands");
if (!node) return TEXT("");
if (!node) return inCaseOfFailureStr;
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
@ -225,11 +265,17 @@ generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID) const
const char *name = element->Attribute("name");
if (name)
{
return wmc.char2wchar(name, _nativeLangEncoding);
string nameStr = name;
if (removeMarkAnd)
{
purifyMenuString(nameStr);
}
return wmc.char2wchar(nameStr.c_str(), _nativeLangEncoding);
}
}
}
return TEXT("");
return inCaseOfFailureStr;
}
generic_string NativeLangSpeaker::getShortcutNameString(int itemID) const

View File

@ -47,7 +47,7 @@ public:
void changeLangTabDropContextMenu(HMENU hCM);
void changeLangTrayIconContexMenu(HMENU hCM);
generic_string getSubMenuEntryName(const char *nodeName) const;
generic_string getNativeLangMenuString(int itemID) const;
generic_string getNativeLangMenuString(int itemID, generic_string inCaseOfFailureStr = L"", bool removeMarkAnd = false) const;
generic_string getShortcutNameString(int itemID) const;
void changeMenuLang(HMENU menuHandle);

View File

@ -592,7 +592,7 @@
// #define IDM_SETTING_HISTORY_SIZE (IDM_SETTING + 3)
// #define IDM_SETTING_EDGE_SIZE (IDM_SETTING + 4)
#define IDM_SETTING_IMPORTPLUGIN (IDM_SETTING + 5)
#define IDM_SETTING_IMPORTSTYLETHEMS (IDM_SETTING + 6)
#define IDM_SETTING_IMPORTSTYLETHEMES (IDM_SETTING + 6)
#define IDM_SETTING_TRAYICON (IDM_SETTING + 8)
#define IDM_SETTING_SHORTCUT_MAPPER (IDM_SETTING + 9)
#define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10)