From 2352cb8d52552da3716fbd6a1295797851ef980a Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 4 Oct 2012 21:21:03 +0000 Subject: [PATCH] [NEW] Make Styler dialog of UDL2 translatable. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@962 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/english.xml | 41 ++++++++++---- PowerEditor/installer/nativeLang/french.xml | 41 ++++++++++---- .../ScitillaComponent/UserDefineDialog.cpp | 6 ++- PowerEditor/src/localization.cpp | 53 ++++++++++++++++--- PowerEditor/src/localization.h | 1 + 5 files changed, 117 insertions(+), 25 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 81d7ea649..eb56ac177 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -363,15 +363,38 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index bc6237d61..a3f556982 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -426,15 +426,6 @@ - - - - - - - - - @@ -446,6 +437,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 4a4365300..c6787e94f 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -28,6 +28,7 @@ #include "precompiledHeaders.h" +#include "localization.h" #include "UserDefineDialog.h" #include "ScintillaEditView.h" #include "Parameters.h" @@ -1486,11 +1487,14 @@ BOOL CALLBACK StylerDlg::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM { StylerDlg * dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop")); NppParameters *pNppParam = NppParameters::getInstance(); - + switch (message) { case WM_INITDIALOG : { + NativeLangSpeaker *pNativeLangSpeaker = pNppParam->getNativeLangSpeaker(); + pNativeLangSpeaker->changeUserDefineLangPopupDlg(hwnd); + ::SetProp(hwnd, TEXT("Styler dialog prop"), (HANDLE)lParam); dlg = (StylerDlg *)::GetProp(hwnd, TEXT("Styler dialog prop")); Style & style = SharedParametersDialog::_pUserLang->_styleArray.getStyler(dlg->stylerIndex); diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 08dc30df7..eeea221a4 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -585,7 +585,7 @@ void NativeLangSpeaker::changeStyleCtrlsLang(HWND hDlg, int *idArray, const char } } -void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) +void NativeLangSpeaker::changeUserDefineLangPopupDlg(HWND hDlg) { if (!_nativeLangA) return; @@ -595,7 +595,47 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) userDefineDlgNode = userDefineDlgNode->FirstChild("UserDefine"); if (!userDefineDlgNode) return; - //UserDefineDialog *userDefineDlg = _pEditView->getUserDefineDlg(); + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + + TiXmlNodeA *stylerDialogNode = userDefineDlgNode->FirstChild("StylerDialog"); + if (!stylerDialogNode) return; + + const char *titre = (stylerDialogNode->ToElement())->Attribute("title"); + if (titre &&titre[0]) + { + const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding); + ::SetWindowText(hDlg, nameW); + } + for (TiXmlNodeA *childNode = stylerDialogNode->FirstChildElement("Item"); + childNode ; + childNode = childNode->NextSibling("Item") ) + { + TiXmlElementA *element = childNode->ToElement(); + int id; + const char *sentinel = element->Attribute("id", &id); + const char *name = element->Attribute("name"); + if (sentinel && (name && name[0])) + { + HWND hItem = ::GetDlgItem(hDlg, id); + if (hItem) + { + const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); + + } + } + } +} + +void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) +{ + if (!_nativeLangA) return; + + TiXmlNodeA *userDefineDlgNode = _nativeLangA->FirstChild("Dialog"); + if (!userDefineDlgNode) return; + + userDefineDlgNode = userDefineDlgNode->FirstChild("UserDefine"); + if (!userDefineDlgNode) return; HWND hDlg = userDefineDlg->getHSelf(); #ifdef UNICODE @@ -613,7 +653,7 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) ::SetWindowText(hDlg, titre); #endif } - // pour ses propres controls + // for each control const int nbControl = 9; const char *translatedText[nbControl]; for (int i = 0 ; i < nbControl ; i++) @@ -654,14 +694,13 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) } } } - const int nbDlg = 4; HWND hDlgArrary[nbDlg]; hDlgArrary[0] = userDefineDlg->getFolderHandle(); hDlgArrary[1] = userDefineDlg->getKeywordsHandle(); hDlgArrary[2] = userDefineDlg->getCommentHandle(); hDlgArrary[3] = userDefineDlg->getSymbolHandle(); - +/* const int nbGrpFolder = 3; int folderID[nbGrpFolder][nbControl] = { //{IDC_DEFAULT_COLORSTYLEGROUP_STATIC, IDC_DEFAULT_FG_STATIC, IDC_DEFAULT_BG_STATIC, IDC_DEFAULT_FONTSTYLEGROUP_STATIC, IDC_DEFAULT_FONTNAME_STATIC, IDC_DEFAULT_FONTSIZE_STATIC, IDC_DEFAULT_BOLD_CHECK, IDC_DEFAULT_ITALIC_CHECK, IDC_DEFAULT_UNDERLINE_CHECK},\ @@ -693,11 +732,12 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) }; int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator}; +*/ const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"}; for (int i = 0 ; i < nbDlg ; i++) { - +/* for (int j = 0 ; j < nbGpArray[i] ; j++) { switch (i) @@ -708,6 +748,7 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) case 3 : changeStyleCtrlsLang(hDlgArrary[i], operatorID[j], translatedText); break; } } +*/ TiXmlNodeA *node = userDefineDlgNode->FirstChild(nodeNameArray[i]); if (node) diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index 47349ea60..e72d42df5 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -54,6 +54,7 @@ public: void changeShortcutmapperLang(ShortcutMapper * sm); void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText); void changeUserDefineLang(UserDefineDialog *userDefineDlg); + void changeUserDefineLangPopupDlg(HWND hDlg); void changeFindReplaceDlgLang(FindReplaceDlg & findReplaceDlg); void changePrefereceDlgLang(PreferenceDlg & preference); bool isRTL() const {