Skip to content

Commit d5a9c7f

Browse files
committed
Make Update available dialog entirely translatable
Fix #33
1 parent 983cbee commit d5a9c7f

4 files changed

Lines changed: 59 additions & 11 deletions

File tree

src/translations/english.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@
2222

2323
<GUP_NativeLangue name="English" version="5.1.3">
2424
<PopupMessages>
25+
<MSGID_UPDATETITLE content="Notepad++ Update Available" />
2526
<MSGID_UPDATEAVAILABLE content="An update package is available, do you want to download and install it?" />
26-
<MSGID_VERSIONCURRENT content="Current version is :" />
27-
<MSGID_VERSIONNEW content="Available version is :" />
27+
<MSGID_VERSIONCURRENT content="Current version is :" />
28+
<MSGID_VERSIONNEW content="Available version is :" />
29+
<MSGID_UPDATEYES content="Yes" />
30+
<MSGID_UPDATEYESSILENT content="Yes (Silent)" />
31+
<MSGID_UPDATENo content="No" />
32+
<MSGID_UPDATENEVER content="Never" />
2833

2934
<MSGID_DOWNLOADPAGE content="Go to the download page" />
3035
<MSGID_MOREINFO content="more info" />

src/translations/french.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222

2323
<GUP_NativeLangue name="français" version="5.1.3">
2424
<PopupMessages>
25+
<MSGID_UPDATETITLE content="Mise à jour de Notepad++ est disponible" />
2526
<MSGID_UPDATEAVAILABLE content="Une mise à jour est disponible, voulez-vous la télécharger et l'installer?"/>
26-
27+
<MSGID_VERSIONCURRENT content="La version courante :" />
28+
<MSGID_VERSIONNEW content="La version disponible :" />
29+
<MSGID_UPDATEYES content="Oui" />
30+
<MSGID_UPDATEYESSILENT content="Oui (Silencieux)" />
31+
<MSGID_UPDATENo content="Non" />
32+
<MSGID_UPDATENEVER content="Jamais" />
33+
2734
<MSGID_DOWNLOADPAGE content="Aller à la page de téléchargement" />
2835
<MSGID_MOREINFO content="plus d'info" />
2936
<!-- $MSGID_DOWNLOADPAGE$ and $MSGID_MOREINFO$ are place holders, don't translate them -->

src/translations/taiwaneseMandarin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222

2323
<GUP_NativeLangue name="台灣繁體" version="5.1.3">
2424
<PopupMessages>
25+
<MSGID_UPDATETITLE content="Notepad++ 可更新的新版本" />
2526
<MSGID_UPDATEAVAILABLE content="有可更新的新版本,您要下載並安裝它嗎?" />
27+
<MSGID_VERSIONCURRENT content="目前版本:" />
28+
<MSGID_VERSIONNEW content="最新版本:" />
29+
<MSGID_UPDATEYES content="" />
30+
<MSGID_UPDATEYESSILENT content="好(安靜簡易)" />
31+
<MSGID_UPDATENo content="不要" />
32+
<MSGID_UPDATENEVER content="永遠不要" />
2633

2734
<MSGID_DOWNLOADPAGE content="進入官方網站下載頁面" />
2835
<MSGID_MOREINFO content="更多相關資訊" />

src/winmain.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ gup -unzipTo [-clean] FOLDER_TO_ACTION ZIP_URL\r\
9797
ZIP_URL: The URL to download zip file.\r\
9898
FOLDER_TO_ACTION: The folder where we clean or/and unzip to.\r\
9999
";
100-
std::wstring thirdDoUpdateDlgButtonLabel;
101100

102101
class DlgIconHelper
103102
{
@@ -608,19 +607,39 @@ LRESULT CALLBACK progressBarDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARA
608607
return FALSE;
609608
}
610609

610+
struct UpdateAvailableDlgStrings
611+
{
612+
wstring _title;
613+
wstring _message;
614+
wstring _customButton;
615+
wstring _yesButton;
616+
wstring _yesSilentButton;
617+
wstring _noButton;
618+
};
611619

612620
LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
613621
{
614622
switch (message)
615623
{
616624
case WM_INITDIALOG:
617625
{
618-
if (thirdDoUpdateDlgButtonLabel != L"")
619-
::SetDlgItemText(hWndDlg, IDCANCEL, thirdDoUpdateDlgButtonLabel.c_str());
620-
621626
if (lParam)
622627
{
623-
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, (LPCWSTR)lParam);
628+
UpdateAvailableDlgStrings* pUaDlgStrs = reinterpret_cast<UpdateAvailableDlgStrings*>(lParam);
629+
630+
if (!(pUaDlgStrs->_message).empty())
631+
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, pUaDlgStrs->_message.c_str());
632+
if (!(pUaDlgStrs->_title).empty())
633+
::SetWindowText(hWndDlg, pUaDlgStrs->_title.c_str());
634+
635+
if (!pUaDlgStrs->_customButton.empty())
636+
::SetDlgItemText(hWndDlg, IDCANCEL, pUaDlgStrs->_customButton.c_str());
637+
if (!pUaDlgStrs->_yesButton.empty())
638+
::SetDlgItemText(hWndDlg, IDYES, pUaDlgStrs->_yesButton.c_str());
639+
if (!pUaDlgStrs->_yesSilentButton.empty())
640+
::SetDlgItemText(hWndDlg, IDOK, pUaDlgStrs->_yesSilentButton.c_str());
641+
if (!pUaDlgStrs->_noButton.empty())
642+
::SetDlgItemText(hWndDlg, IDNO, pUaDlgStrs->_noButton.c_str());
624643
}
625644

626645
goToScreenCenter(hWndDlg);
@@ -1380,7 +1399,12 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
13801399
// Process Update Info
13811400
//
13821401

1383-
// Ask user if he/she want to do update
1402+
// Ask if user wants to do update
1403+
1404+
UpdateAvailableDlgStrings uaDlgStrs;
1405+
uaDlgStrs._title = nativeLang.getMessageString("MSGID_UPDATETITLE");
1406+
1407+
13841408
wstring updateAvailable = nativeLang.getMessageString("MSGID_UPDATEAVAILABLE");
13851409
if (updateAvailable.empty())
13861410
updateAvailable = MSGID_UPDATEAVAILABLE;
@@ -1398,10 +1422,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
13981422
updateAvailable += L"\n\n" + versionCurrent;
13991423
updateAvailable += L"\n" + versionNew;
14001424

1401-
thirdDoUpdateDlgButtonLabel = gupParams.get3rdButtonLabel();
1425+
uaDlgStrs._message = updateAvailable;
1426+
1427+
uaDlgStrs._customButton = nativeLang.getMessageString("MSGID_UPDATENEVER");
1428+
uaDlgStrs._yesButton = nativeLang.getMessageString("MSGID_UPDATEYES");
1429+
uaDlgStrs._yesSilentButton = nativeLang.getMessageString("MSGID_UPDATEYESSILENT");
1430+
uaDlgStrs._noButton = nativeLang.getMessageString("MSGID_UPDATENo");
14021431

14031432
int dlAnswer = 0;
1404-
dlAnswer = static_cast<int32_t>(::DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), hApp, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc), (LPARAM)updateAvailable.c_str()));
1433+
dlAnswer = static_cast<int32_t>(::DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), hApp, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc), (LPARAM)&uaDlgStrs));
14051434

14061435
if (dlAnswer == IDNO)
14071436
{

0 commit comments

Comments
 (0)