From 06b88e3faf58243eb4fb2c574cc751a80be1fc10 Mon Sep 17 00:00:00 2001 From: lx-s Date: Mon, 6 Nov 2023 22:12:48 +0100 Subject: [PATCH] TrayMenu translatable --- Translations/wm_de/wm_de.rc | Bin 11610 -> 11610 bytes WinMute/WinMute.cpp | 33 +++++++++++++++++++++++++++++++++ WinMute/WinMute.h | 2 ++ WinMute/common.h | 1 + 4 files changed, 36 insertions(+) diff --git a/Translations/wm_de/wm_de.rc b/Translations/wm_de/wm_de.rc index a1df66f7907c90d4156c838edc92ac37250c9d2a..50f980dc83436ba2c2ca25a840b1822412aa7dac 100644 GIT binary patch delta 24 fcmcZ=bt`H^m@2y`LmopKL;hq#4a3cSs%O{%a#sj_ delta 24 gcmcZ=bt`H^m@4}nh9rhmhN8)a8it$uRL`&j0DAEW1^@s6 diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index 9d201f4..b5e79b0 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -226,6 +226,8 @@ bool WinMute::InitTrayMenu() !CHECK_MENU_ITEM(MUTEONLOGOUT, muteCtrl_.GetMuteOnLogout())) { return false; } + + LoadMainMenuText(); return true; } #undef CHECK_MENU_ITEM @@ -387,6 +389,37 @@ void WinMute::ToggleMenuCheck(UINT item, bool* setting) noexcept } } +void WinMute::LoadMainMenuText() +{ + std::map menuText; + menuText[ID_TRAYMENU_INFO] = i18n.GetTextW(IDS_TRAYMENU_INFO); + menuText[ID_TRAYMENU_LABEL_MUTEWHEN] = i18n.GetTextW(IDS_TRAYMENU_MUTEWHEN); + menuText[ID_TRAYMENU_MUTEONLOCK] = i18n.GetTextW(IDS_TRAYMENU_MUTEONLOCK); + menuText[ID_TRAYMENU_MUTEONSCREENSUSPEND] = i18n.GetTextW(IDS_TRAYMENU_MUTEONSCREENSUSPEND); + menuText[ID_TRAYMENU_RESTOREAUDIO] = i18n.GetTextW(IDS_TRAYMENU_RESTOREVOLUME); + menuText[ID_TRAYMENU_LABEL_MUTEON_NO_RESTORE] = i18n.GetTextW(IDS_TRAYMENU_MUTEON_NO_RESTORE); + menuText[ID_TRAYMENU_MUTEONSHUTDOWN] = i18n.GetTextW(IDS_TRAYMENU_MUTEON_SHUTDOWN); + menuText[ID_TRAYMENU_MUTEONSUSPEND] = i18n.GetTextW(IDS_TRAYMENU_MUTEON_SLEEP); + menuText[ID_TRAYMENU_MUTEONLOGOUT] = i18n.GetTextW(IDS_TRAYMENU_MUTEON_LOGOUT); + menuText[ID_TRAYMENU_MUTE] = i18n.GetTextW(IDS_TRAYMENU_MUTE_ALL_DEVICES); + menuText[ID_TRAYMENU_SETTINGS] = i18n.GetTextW(IDS_TRAYMENU_SETTINGS); + menuText[ID_TRAYMENU_EXIT] = i18n.GetTextW(IDS_TRAYMENU_EXIT); + + for (const auto& mt : menuText) { + MENUITEMINFO mii{ sizeof(MENUITEMINFO) }; + if (!GetMenuItemInfo(hTrayMenu_, mt.first, false, &mii)) { + continue; + } + mii.fMask = MIIM_TYPE; + mii.fType = MFT_STRING; + mii.dwTypeData = const_cast(mt.second.c_str()); + mii.cch = static_cast(mt.second.length()); + if (!SetMenuItemInfo(hTrayMenu_, mt.first, false, &mii)) { + continue; + } + } +} + LRESULT WinMute::OnCommand(HWND hWnd, WPARAM wParam, LPARAM) { switch (LOWORD(wParam)) { diff --git a/WinMute/WinMute.h b/WinMute/WinMute.h index 9f901c7..e346b98 100644 --- a/WinMute/WinMute.h +++ b/WinMute/WinMute.h @@ -82,6 +82,8 @@ private: void ToggleMenuCheck(UINT item, bool* setting) noexcept; + void LoadMainMenuText(); + // Windows Callback LRESULT OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam); LRESULT OnTrayIcon(HWND hWnd, WPARAM wParam, LPARAM lParam); diff --git a/WinMute/common.h b/WinMute/common.h index 628df31..820595c 100644 --- a/WinMute/common.h +++ b/WinMute/common.h @@ -70,6 +70,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include namespace fs = std::filesystem; -- 2.43.0