From aea55f662af6c125b5912dfc872786aa30bb2909 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 30 Apr 2021 09:57:30 +0200 Subject: [PATCH] i18n: move to separate .h file So that we can include it where needed and don't cause redefined _() macros for other projects. Fixes #1120 --- src/daemon/pipewire.c | 2 ++ src/examples/media-session/alsa-monitor.c | 2 +- src/pipewire/i18n.h | 44 +++++++++++++++++++++++ src/pipewire/pipewire.h | 7 ---- src/tools/pw-cat.c | 2 +- src/tools/pw-cli.c | 1 + 6 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 src/pipewire/i18n.h diff --git a/src/daemon/pipewire.c b/src/daemon/pipewire.c index 61493521b..753248e6b 100644 --- a/src/daemon/pipewire.c +++ b/src/daemon/pipewire.c @@ -30,6 +30,8 @@ #include #include +#include + #include "config.h" static void do_quit(void *data, int signal_number) diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index a67c7fe64..b625236f2 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include "media-session.h" diff --git a/src/pipewire/i18n.h b/src/pipewire/i18n.h new file mode 100644 index 000000000..4be1d485a --- /dev/null +++ b/src/pipewire/i18n.h @@ -0,0 +1,44 @@ +/* PipeWire + * + * Copyright © 2021 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_I18N_H +#define PIPEWIRE_I18N_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +const char *pw_gettext(const char *msgid); +const char *pw_ngettext(const char *msgid, const char *msgid_plural, unsigned long int n); + +#define _(String) (pw_gettext(String)) +#define N_(String) (String) + +#ifdef __cplusplus +} +#endif + +#endif /* PIPEWIRE_I18N_H */ diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index 02c236b4d..1e9271eab 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -30,7 +30,6 @@ extern "C" { #endif #include -#include #include #include @@ -155,12 +154,6 @@ struct spa_handle *pw_load_spa_handle(const char *lib, int pw_unload_spa_handle(struct spa_handle *handle); -const char *pw_gettext(const char *msgid); -const char *pw_ngettext(const char *msgid, const char *msgid_plural, unsigned long int n); - -#define _(String) (pw_gettext(String)) -#define N_(String) (String) - #ifdef __cplusplus } #endif diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 7eb13da91..7d0fcfa71 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include "midifile.h" diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index ddc316989..9afd036c3 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -42,6 +42,7 @@ #include #include +#include #include