From 9627494043d3ace4d4b5ab04b85fbdd0bd5a87a5 Mon Sep 17 00:00:00 2001
From: ArkadiuszMichalski <2730894+ArkadiuszMichalski@users.noreply.github.com>
Date: Tue, 14 Feb 2023 19:09:58 +0100
Subject: [PATCH] Fix translation issue for Dock/Undock label in User-Defined
dialog
Fix 8020, close #13127
---
PowerEditor/installer/nativeLang/english.xml | 1 +
.../nativeLang/english_customizable.xml | 1 +
.../ScintillaComponent/UserDefineDialog.cpp | 27 +++++++++++++++++--
.../ScintillaComponent/UserDefineResource.h | 1 +
PowerEditor/src/localization.cpp | 23 ++++++++++++++++
PowerEditor/src/localization.h | 1 +
6 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index 3b8508767..c3379fb6a 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -722,6 +722,7 @@ The comments are here for explanation, it's not necessary to translate them.
+
diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml
index d43afc3fb..69c21181a 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -650,6 +650,7 @@
+
diff --git a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp
index d2a583a82..e192a8d79 100644
--- a/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp
+++ b/PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp
@@ -925,9 +925,32 @@ void UserDefineDialog::reloadLangCombo()
void UserDefineDialog::changeStyle()
{
_status = !_status;
- ::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, (_status == DOCK)?TEXT("Undock"):TEXT("Dock"));
+ NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
+ TiXmlNodeA *targetNode = nullptr;
+ if (pNativeSpeaker->getNativeLangA())
+ {
+ targetNode = (pNativeSpeaker->getNativeLangA())->FirstChildElement("Dialog");
+ if (targetNode)
+ targetNode = targetNode->FirstChildElement("UserDefine");
+ }
+ generic_string dockButtonLabel;
+ generic_string defauleLabel;
+ string idStr;
+ if (_status == DOCK)
+ {
+ defauleLabel = TEXT("Undock");
+ idStr = std::to_string(IDC_UNDOCK_BUTTON);
+ }
+ else
+ {
+ defauleLabel = TEXT("Dock");
+ idStr = std::to_string(IDC_DOCK_BUTTON);
+ }
+
+ dockButtonLabel= pNativeSpeaker->getAttrNameByIdStr(defauleLabel.c_str(), targetNode, idStr.c_str());
+ ::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, dockButtonLabel.c_str());
- auto style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
+ auto style = ::GetWindowLongPtr(_hSelf, GWL_STYLE);
if (!style)
::MessageBox(NULL, TEXT("GetWindowLongPtr failed in UserDefineDialog::changeStyle()"), TEXT(""), MB_OK);
diff --git a/PowerEditor/src/ScintillaComponent/UserDefineResource.h b/PowerEditor/src/ScintillaComponent/UserDefineResource.h
index f09a41e29..5838469e3 100644
--- a/PowerEditor/src/ScintillaComponent/UserDefineResource.h
+++ b/PowerEditor/src/ScintillaComponent/UserDefineResource.h
@@ -35,6 +35,7 @@
#define IDC_AUTOCOMPLET_STATIC (IDD_GLOBAL_USERDEFINE_DLG + 14)
#define IDC_IMPORT_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 15)
#define IDC_EXPORT_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 16)
+ #define IDC_UNDOCK_BUTTON (IDD_GLOBAL_USERDEFINE_DLG + 17)
#define IDD_FOLDER_STYLE_DLG 21000 // IDD_GLOBAL_USERDEFINE_DLG + 1000
#define IDC_DEFAULT (IDD_FOLDER_STYLE_DLG + 100)
diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp
index 95c8b67a9..71ba8af7e 100644
--- a/PowerEditor/src/localization.cpp
+++ b/PowerEditor/src/localization.cpp
@@ -1331,6 +1331,29 @@ generic_string NativeLangSpeaker::getAttrNameStr(const TCHAR *defaultStr, const
return defaultStr;
}
+ generic_string NativeLangSpeaker::getAttrNameByIdStr(const TCHAR *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name, const char *nodeL2Name) const
+{
+ if (!targetNode) return defaultStr;
+
+ for (TiXmlNodeA *childNode = targetNode->FirstChildElement("Item");
+ childNode;
+ childNode = childNode->NextSibling("Item"))
+ {
+ TiXmlElementA *element = childNode->ToElement();
+ const char *id = element->Attribute(nodeL1Name);
+ if (id && id[0] && !strcmp(id, nodeL1Value))
+ {
+ const char *name = element->Attribute(nodeL2Name);
+ if (name && name[0])
+ {
+ WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
+ return wmc.char2wchar(name, _nativeLangEncoding);
+ }
+ }
+ }
+ return defaultStr;
+}
+
int NativeLangSpeaker::messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *defaultMessage, const TCHAR *defaultTitle, int msgBoxType, int intInfo, const TCHAR *strInfo)
{
if ((NppParameters::getInstance()).isEndSessionCritical())
diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h
index ba5e3f588..c299ee0d2 100644
--- a/PowerEditor/src/localization.h
+++ b/PowerEditor/src/localization.h
@@ -80,6 +80,7 @@ public:
generic_string getProjectPanelLangMenuStr(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, const char *nodeL3Name = "name") const;
+ generic_string getAttrNameByIdStr(const TCHAR *defaultStr, TiXmlNodeA *targetNode, const char *nodeL1Value, const char *nodeL1Name = "id", const char *nodeL2Name = "name") const;
generic_string getLocalizedStrFromID(const char *strID, const generic_string& defaultString) const;
int messageBox(const char *msgBoxTagName, HWND hWnd, const TCHAR *message, const TCHAR *title, int msgBoxType, int intInfo = 0, const TCHAR *strInfo = NULL);