From 59ce19333e004c55645951beb850dc5a3abd5444 Mon Sep 17 00:00:00 2001 From: rbuj Date: Thu, 18 Feb 2021 12:25:55 +0100 Subject: build: allow users to disable gettext support (--disable-nls) --- Makefile.am | 6 +++++- configure.ac | 4 +++- data/Makefile.am | 8 ++++++++ src/capplet/mate-notification-applet.c | 4 ++++ src/capplet/mate-notification-properties.c | 2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index c436a21..4f4dbfb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,8 @@ -SUBDIRS = po data src +if USE_NLS +PO_SUBDIR = po +endif + +SUBDIRS = $(PO_SUBDIR) data src # Point to our macro directory and pick up user flags from the environment ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} diff --git a/configure.ac b/configure.ac index af9be0d..a544d39 100644 --- a/configure.ac +++ b/configure.ac @@ -75,9 +75,10 @@ dnl --------------------------------------------------------------------------- dnl i18n stuff dnl --------------------------------------------------------------------------- +AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.19.8]) AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8]) -AM_GNU_GETTEXT([external]) +AM_CONDITIONAL([USE_NLS], [test "x${USE_NLS}" = "xyes"]) AC_SUBST([GETTEXT_PACKAGE], [mate-notification-daemon]) AC_DEFINE([GETTEXT_PACKAGE], [PACKAGE_TARNAME], [Define to the gettext package name.]) @@ -314,6 +315,7 @@ echo " warning flags: ${WARN_CFLAGS} Wayland support: ${have_wayland} X11 support: ${have_x11} + Native Language support: ${USE_NLS} dbus-1 system.d $DBUS_SYS_DIR dbus-1 services $DBUS_SERVICES_DIR diff --git a/data/Makefile.am b/data/Makefile.am index be9a8b7..a666d7a 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,14 +21,22 @@ applet_DATA = org.mate.applets.MateNotificationApplet.mate-panel-applet applet_in_files = $(applet_DATA:.mate-panel-applet=.desktop.in) $(applet_DATA): $(applet_in_files) +if USE_NLS $(AM_V_GEN) $(MSGFMT) --desktop --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ +else + $(AM_V_GEN) cp -f $< $@ +endif desktopdir = $(datadir)/applications desktop_DATA = mate-notification-properties.desktop desktop_in_files = $(desktop_DATA:.desktop=.desktop.in) $(desktop_DATA): $(desktop_in_files) +if USE_NLS $(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ +else + $(AM_V_GEN) sed '/^# Translators/d' < $< > $@ +endif gsettings_SCHEMAS = org.mate.NotificationDaemon.gschema.xml gsettingsschema_in_files = $(gsettings_SCHEMAS:=.in) diff --git a/src/capplet/mate-notification-applet.c b/src/capplet/mate-notification-applet.c index 04a799d..ec10acc 100644 --- a/src/capplet/mate-notification-applet.c +++ b/src/capplet/mate-notification-applet.c @@ -166,9 +166,11 @@ applet_main (MatePanelApplet *applet_widget) MateNotificationApplet *applet; GtkWidget *box; +#ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); +#endif /* ENABLE_NLS */ g_set_application_name (_("Do Not Disturb")); gtk_window_set_default_icon_name ("mate-notification-properties"); @@ -202,7 +204,9 @@ applet_main (MatePanelApplet *applet_widget) /* set up context menu */ applet->action_group = gtk_action_group_new ("Do Not Disturb Actions"); +#ifdef ENABLE_NLS gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE); +#endif /* ENABLE_NLS */ gtk_action_group_add_actions (applet->action_group, applet_menu_actions, G_N_ELEMENTS (applet_menu_actions), applet); diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index 154029d..7d43455 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -511,9 +511,11 @@ int main(int argc, char** argv) { NotificationAppletDialog dialog = {NULL, }; /* <- ? */ +#ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, NOTIFICATION_LOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); +#endif /* ENABLE_NLS */ gtk_init(&argc, &argv); -- cgit v1.2.1