From 03bf98fe2046a0756931be6f7fa330e5473262db Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Mon, 25 Nov 2024 22:30:56 +0100 Subject: [PATCH] Add header for i18n macros --- client/application.h | 5 ----- client/scenes/lobby.cpp | 1 + client/scenes/lobby_gui.cpp | 1 + client/scenes/stream_stats.cpp | 1 + client/utils/i18n.h | 24 ++++++++++++++++++++++++ client/wivrn_client.cpp | 8 ++++---- 6 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 client/utils/i18n.h diff --git a/client/application.h b/client/application.h index 1c52211c..04bd1131 100644 --- a/client/application.h +++ b/client/application.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -48,10 +47,6 @@ #include #include -#define _(x) boost::locale::gettext(x) -#define _F(x) fmt::runtime(boost::locale::gettext(x)) -#define _S(x) boost::locale::gettext(x).c_str() - class scene; #ifdef __ANDROID__ diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index 6efa0d2d..8384533b 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -29,6 +29,7 @@ #include "render/scene_data.h" #include "render/scene_renderer.h" #include "stream.h" +#include "utils/i18n.h" #include "utils/overloaded.h" #include "wivrn_client.h" #include "wivrn_discover.h" diff --git a/client/scenes/lobby_gui.cpp b/client/scenes/lobby_gui.cpp index a2b57113..b6f1c06d 100644 --- a/client/scenes/lobby_gui.cpp +++ b/client/scenes/lobby_gui.cpp @@ -29,6 +29,7 @@ #include "implot.h" #include "lobby.h" #include "stream.h" +#include "utils/i18n.h" #include "version.h" #include #include diff --git a/client/scenes/stream_stats.cpp b/client/scenes/stream_stats.cpp index 3e48e10f..7877be05 100644 --- a/client/scenes/stream_stats.cpp +++ b/client/scenes/stream_stats.cpp @@ -24,6 +24,7 @@ #include "application.h" #include "imgui_internal.h" #include "implot.h" +#include "utils/i18n.h" #include "utils/ranges.h" #include #include diff --git a/client/utils/i18n.h b/client/utils/i18n.h new file mode 100644 index 00000000..3a7b32d1 --- /dev/null +++ b/client/utils/i18n.h @@ -0,0 +1,24 @@ +/* + * WiVRn VR streaming + * Copyright (C) 2024 Guillaume Meunier + * Copyright (C) 2024 Patrick Nicolas + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#define _(x) boost::locale::gettext(x) +#define _F(x) fmt::runtime(boost::locale::gettext(x)) +#define _S(x) boost::locale::gettext(x).c_str() diff --git a/client/wivrn_client.cpp b/client/wivrn_client.cpp index e8ec5818..dfd5506f 100644 --- a/client/wivrn_client.cpp +++ b/client/wivrn_client.cpp @@ -21,9 +21,9 @@ #include "hardware.h" #include "secrets.h" #include "spdlog/common.h" +#include "utils/i18n.h" #include "wivrn_packets.h" #include -#include #include #include #include @@ -93,7 +93,7 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke } if (std::chrono::steady_clock::now() >= timeout_abs) - throw std::runtime_error(boost::locale::gettext("Timeout")); + throw std::runtime_error(_("Timeout")); } }; @@ -151,7 +151,7 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke case to_headset::crypto_handshake::crypto_state::enroll_disabled: spdlog::info("Pairing is disabled on server"); - throw std::runtime_error(boost::locale::gettext("Pairing is disabled on server")); + throw std::runtime_error(_("Pairing is disabled on server")); } // may be on control socket if forced TCP @@ -167,7 +167,7 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke } if (std::chrono::steady_clock::now() >= timeout) - throw std::runtime_error(boost::locale::gettext("Timeout")); + throw std::runtime_error(_("Timeout")); // If using stream socket, the handshake might be lost if (stream)