From 0c0a202d265613854cc1f9646e1b791091a4a2b8 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Wed, 19 Mar 2025 16:29:53 +0100 Subject: [PATCH] Add optional context for client translations --- client/scenes/lobby_gui.cpp | 4 ++-- client/utils/i18n.h | 1 + locale/fr/wivrn.po | 3 ++- locale/it/wivrn.po | 3 ++- tools/check_messages.sh | 1 + tools/update_messages.sh | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index 615c825b..306acccf 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -585,9 +585,9 @@ void scenes::lobby::gui_settings() if (not refresh_rates.empty()) { float active_rate = config.preferred_refresh_rate.value_or(refresh_rates.back()); - if (ImGui::BeginCombo(_S("Refresh rate"), active_rate ? fmt::format("{}", active_rate).c_str() : _S("Automatic"))) + if (ImGui::BeginCombo(_S("Refresh rate"), active_rate ? fmt::format("{}", active_rate).c_str() : _cS("automatic refresh rate", "Automatic"))) { - if (ImGui::Selectable(_S("Automatic"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease)) + if (ImGui::Selectable(_cS("automatic refresh rate", "Automatic"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease)) { session.set_refresh_rate(0); config.preferred_refresh_rate = 0; diff --git a/client/utils/i18n.h b/client/utils/i18n.h index 3a7b32d1..9f77be21 100644 --- a/client/utils/i18n.h +++ b/client/utils/i18n.h @@ -22,3 +22,4 @@ #define _(x) boost::locale::gettext(x) #define _F(x) fmt::runtime(boost::locale::gettext(x)) #define _S(x) boost::locale::gettext(x).c_str() +#define _cS(c, x) boost::locale::pgettext(c, x).c_str() diff --git a/locale/fr/wivrn.po b/locale/fr/wivrn.po index 008de54b..b86ee273 100644 --- a/locale/fr/wivrn.po +++ b/locale/fr/wivrn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WiVRn 0.15\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-19 16:08+0100\n" +"POT-Creation-Date: 2025-03-19 16:28+0100\n" "PO-Revision-Date: 2024-05-20 13:00+0200\n" "Last-Translator: Guillaume Meunier \n" "Language: French\n" @@ -133,6 +133,7 @@ msgid "Refresh rate" msgstr "Taux de rafraichissement" #: client/scenes/lobby_gui.cpp:588 client/scenes/lobby_gui.cpp:590 +msgctxt "automatic refresh rate" msgid "Automatic" msgstr "Automatique" diff --git a/locale/it/wivrn.po b/locale/it/wivrn.po index c5585b77..89d5d1f0 100644 --- a/locale/it/wivrn.po +++ b/locale/it/wivrn.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: WiVRn 0.15\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-03-19 16:08+0100\n" +"POT-Creation-Date: 2025-03-19 16:28+0100\n" "PO-Revision-Date: 2024-10-15 20:16+0100\n" "Last-Translator: Albano Battistella \n" "Language: Italian\n" @@ -132,6 +132,7 @@ msgid "Refresh rate" msgstr "Frequenza di aggiornamento" #: client/scenes/lobby_gui.cpp:588 client/scenes/lobby_gui.cpp:590 +msgctxt "automatic refresh rate" msgid "Automatic" msgstr "Automatica" diff --git a/tools/check_messages.sh b/tools/check_messages.sh index c0999797..73917740 100755 --- a/tools/check_messages.sh +++ b/tools/check_messages.sh @@ -9,6 +9,7 @@ xgettext \ --c++ --from-code=UTF-8 \ --keyword=_:1,1t \ --keyword=_S:1,1t \ + --keyword=_cS:1c,2,2t \ --keyword=_F:1,1t \ --output=$WIVRN_CLIENT_POT \ --package-name=WiVRn \ diff --git a/tools/update_messages.sh b/tools/update_messages.sh index 252400df..f2b33f7f 100755 --- a/tools/update_messages.sh +++ b/tools/update_messages.sh @@ -9,6 +9,7 @@ xgettext \ --c++ --from-code=UTF-8 \ --keyword=_:1,1t \ --keyword=_S:1,1t \ + --keyword=_cS:1c,2,2t \ --keyword=_F:1,1t \ --output=$WIVRN_CLIENT_POT \ --package-name=WiVRn \