libpurple: Include 'glib/gi18n-lib.h' instead of 'libintl.h'

Sat, 08 Dec 2018 22:01:50 -0600

author
Mike Ruprecht <cmaiku@gmail.com>
date
Sat, 08 Dec 2018 22:01:50 -0600
changeset 39373
47667f5c6696
parent 39372
43e3da39daf6
child 39374
d6261d7d0c91

libpurple: Include 'glib/gi18n-lib.h' instead of 'libintl.h'

This patch replaces includes of 'libintl.h' with 'glib/gi18n-lib.h'.
The latter defines the macros we use, so we can remove our manual
fallbacks. It also removes 'locale.h' from 'internal.h' as it's
included only where needed now. Lastly, it defines GETTEXT_PACKAGE
to be the same as the PACKAGE define. 'glib/gi18n-lib.h' uses this
for its i18n macros.

libpurple/internal.h file | annotate | diff | comparison | revisions
libpurple/win32/libc_interface.c file | annotate | diff | comparison | revisions
meson.build file | annotate | diff | comparison | revisions
--- a/libpurple/internal.h	Sat Dec 08 21:59:14 2018 -0600
+++ b/libpurple/internal.h	Sat Dec 08 22:01:50 2018 -0600
@@ -36,36 +36,8 @@
 #ifdef SKYOS
 #include <net/sockios.h>
 #endif
-/*
- * If we're using NLS, make sure gettext works.  If not, then define
- * dummy macros in place of the normal gettext macros.
- *
- * Also, the perl XS config.h file sometimes defines _  So we need to
- * make sure _ isn't already defined before trying to define it.
- *
- * The Singular/Plural/Number ngettext dummy definition below was
- * taken from an email to the texinfo mailing list by Manuel Guerrero.
- * Thank you Manuel, and thank you Alex's good friend Google.
- */
-#ifdef ENABLE_NLS
-#  include <locale.h>
-#  include <libintl.h>
-#  undef printf
-#  define _(String) ((const char *)dgettext(PACKAGE, String))
-#  ifdef gettext_noop
-#    define N_(String) gettext_noop (String)
-#  else
-#    define N_(String) (String)
-#  endif
-#else
-#  include <locale.h>
-#  define N_(String) (String)
-#  ifndef _
-#    define _(String) ((const char *)String)
-#  endif
-#  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
-#  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
-#endif
+
+#include <glib/gi18n-lib.h>
 
 #ifdef HAVE_ENDIAN_H
 # include <endian.h>
--- a/libpurple/win32/libc_interface.c	Sat Dec 08 21:59:14 2018 -0600
+++ b/libpurple/win32/libc_interface.c	Sat Dec 08 22:01:50 2018 -0600
@@ -21,6 +21,7 @@
 
 #include <config.h>
 
+#include <glib/gi18n-lib.h>
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <io.h>
@@ -37,26 +38,6 @@
 #include <glib/gstdio.h>
 #include "util.h"
 
-/** This is redefined here because we can't include internal.h */
-#ifdef ENABLE_NLS
-#  include <locale.h>
-#  include <libintl.h>
-#  define _(String) ((const char *)dgettext(PACKAGE, String))
-#  ifdef gettext_noop
-#    define N_(String) gettext_noop (String)
-#  else
-#    define N_(String) (String)
-#  endif
-#else
-#  include <locale.h>
-#  define N_(String) (String)
-#  ifndef _
-#    define _(String) ((const char *)String)
-#  endif
-#  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
-#  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
-#endif
-
 #ifndef S_ISDIR
 # define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
 #endif
--- a/meson.build	Sat Dec 08 21:59:14 2018 -0600
+++ b/meson.build	Sat Dec 08 22:01:50 2018 -0600
@@ -37,6 +37,7 @@
 purple_h_conf = configuration_data()
 version_conf = configuration_data()
 
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
 conf.set_quoted('PACKAGE', meson.project_name())
 conf.set_quoted('PACKAGE_NAME', meson.project_name())
 conf.set_quoted('VERSION', purple_display_version)

mercurial