Skip to content

Commit

Permalink
Make Update available dialog entirely translatable
Browse files Browse the repository at this point in the history
Fix #33
  • Loading branch information
donho committed Jun 26, 2024
1 parent 983cbee commit d5a9c7f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/translations/english.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@

<GUP_NativeLangue name="English" version="5.1.3">
<PopupMessages>
<MSGID_UPDATETITLE content="Notepad++ Update Available" />
<MSGID_UPDATEAVAILABLE content="An update package is available, do you want to download and install it?" />
<MSGID_VERSIONCURRENT content="Current version is :" />
<MSGID_VERSIONNEW content="Available version is :" />
<MSGID_VERSIONCURRENT content="Current version is :" />
<MSGID_VERSIONNEW content="Available version is :" />
<MSGID_UPDATEYES content="Yes" />
<MSGID_UPDATEYESSILENT content="Yes (Silent)" />
<MSGID_UPDATENo content="No" />
<MSGID_UPDATENEVER content="Never" />

<MSGID_DOWNLOADPAGE content="Go to the download page" />
<MSGID_MOREINFO content="more info" />
Expand Down
9 changes: 8 additions & 1 deletion src/translations/french.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@

<GUP_NativeLangue name="français" version="5.1.3">
<PopupMessages>
<MSGID_UPDATETITLE content="Mise à jour de Notepad++ est disponible" />
<MSGID_UPDATEAVAILABLE content="Une mise à jour est disponible, voulez-vous la télécharger et l'installer?"/>

<MSGID_VERSIONCURRENT content="La version courante :" />
<MSGID_VERSIONNEW content="La version disponible :" />
<MSGID_UPDATEYES content="Oui" />
<MSGID_UPDATEYESSILENT content="Oui (Silencieux)" />
<MSGID_UPDATENo content="Non" />
<MSGID_UPDATENEVER content="Jamais" />

<MSGID_DOWNLOADPAGE content="Aller à la page de téléchargement" />
<MSGID_MOREINFO content="plus d'info" />
<!-- $MSGID_DOWNLOADPAGE$ and $MSGID_MOREINFO$ are place holders, don't translate them -->
Expand Down
7 changes: 7 additions & 0 deletions src/translations/taiwaneseMandarin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@

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

<MSGID_DOWNLOADPAGE content="進入官方網站下載頁面" />
<MSGID_MOREINFO content="更多相關資訊" />
Expand Down
45 changes: 37 additions & 8 deletions src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ gup -unzipTo [-clean] FOLDER_TO_ACTION ZIP_URL\r\
ZIP_URL: The URL to download zip file.\r\
FOLDER_TO_ACTION: The folder where we clean or/and unzip to.\r\
";
std::wstring thirdDoUpdateDlgButtonLabel;

class DlgIconHelper
{
Expand Down Expand Up @@ -608,19 +607,39 @@ LRESULT CALLBACK progressBarDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARA
return FALSE;
}

struct UpdateAvailableDlgStrings
{
wstring _title;
wstring _message;
wstring _customButton;
wstring _yesButton;
wstring _yesSilentButton;
wstring _noButton;
};

LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
if (thirdDoUpdateDlgButtonLabel != L"")
::SetDlgItemText(hWndDlg, IDCANCEL, thirdDoUpdateDlgButtonLabel.c_str());

if (lParam)
{
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, (LPCWSTR)lParam);
UpdateAvailableDlgStrings* pUaDlgStrs = reinterpret_cast<UpdateAvailableDlgStrings*>(lParam);

if (!(pUaDlgStrs->_message).empty())
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, pUaDlgStrs->_message.c_str());
if (!(pUaDlgStrs->_title).empty())
::SetWindowText(hWndDlg, pUaDlgStrs->_title.c_str());

if (!pUaDlgStrs->_customButton.empty())
::SetDlgItemText(hWndDlg, IDCANCEL, pUaDlgStrs->_customButton.c_str());
if (!pUaDlgStrs->_yesButton.empty())
::SetDlgItemText(hWndDlg, IDYES, pUaDlgStrs->_yesButton.c_str());
if (!pUaDlgStrs->_yesSilentButton.empty())
::SetDlgItemText(hWndDlg, IDOK, pUaDlgStrs->_yesSilentButton.c_str());
if (!pUaDlgStrs->_noButton.empty())
::SetDlgItemText(hWndDlg, IDNO, pUaDlgStrs->_noButton.c_str());
}

goToScreenCenter(hWndDlg);
Expand Down Expand Up @@ -1380,7 +1399,12 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
// Process Update Info
//

// Ask user if he/she want to do update
// Ask if user wants to do update

UpdateAvailableDlgStrings uaDlgStrs;
uaDlgStrs._title = nativeLang.getMessageString("MSGID_UPDATETITLE");


wstring updateAvailable = nativeLang.getMessageString("MSGID_UPDATEAVAILABLE");
if (updateAvailable.empty())
updateAvailable = MSGID_UPDATEAVAILABLE;
Expand All @@ -1398,10 +1422,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
updateAvailable += L"\n\n" + versionCurrent;
updateAvailable += L"\n" + versionNew;

thirdDoUpdateDlgButtonLabel = gupParams.get3rdButtonLabel();
uaDlgStrs._message = updateAvailable;

uaDlgStrs._customButton = nativeLang.getMessageString("MSGID_UPDATENEVER");
uaDlgStrs._yesButton = nativeLang.getMessageString("MSGID_UPDATEYES");
uaDlgStrs._yesSilentButton = nativeLang.getMessageString("MSGID_UPDATEYESSILENT");
uaDlgStrs._noButton = nativeLang.getMessageString("MSGID_UPDATENo");

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

if (dlAnswer == IDNO)
{
Expand Down

0 comments on commit d5a9c7f

Please sign in to comment.