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
This commit is contained in:
Wim Taymans 2021-04-30 09:57:30 +02:00
parent f489e32e44
commit aea55f662a
6 changed files with 49 additions and 9 deletions

View file

@ -30,6 +30,8 @@
#include <spa/utils/result.h>
#include <pipewire/pipewire.h>
#include <pipewire/i18n.h>
#include "config.h"
static void do_quit(void *data, int signal_number)

View file

@ -50,7 +50,7 @@
#include <spa/support/dbus.h>
#include <pipewire/pipewire.h>
#include <pipewire/main-loop.h>
#include <pipewire/i18n.h>
#include <extensions/session-manager.h>
#include "media-session.h"

44
src/pipewire/i18n.h Normal file
View file

@ -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 <spa/support/i18n.h>
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 */

View file

@ -30,7 +30,6 @@ extern "C" {
#endif
#include <spa/support/plugin.h>
#include <spa/support/i18n.h>
#include <pipewire/array.h>
#include <pipewire/client.h>
@ -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

View file

@ -46,7 +46,7 @@
#include <spa/debug/types.h>
#include <pipewire/pipewire.h>
#include <pipewire/global.h>
#include <pipewire/i18n.h>
#include <extensions/metadata.h>
#include "midifile.h"

View file

@ -42,6 +42,7 @@
#include <spa/pod/builder.h>
#include <pipewire/impl.h>
#include <pipewire/i18n.h>
#include <extensions/session-manager.h>