From 7578472e39bbf4f23985a30858e1b7d324b39c9a Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 25 Jan 2021 21:55:28 +0100 Subject: build: allow users to disable gettext support (--disable-nls) --- Makefile.am | 6 +++++- configure.ac | 5 +++-- desktop-directories/Makefile.am | 4 ++++ po/POTFILES.in | 1 + util/test-menu-spec.c | 8 ++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 084ca65..14434e7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,8 @@ -SUBDIRS = po libmenu desktop-directories layout util +if USE_NLS +PO_SUBDIR = po +endif + +SUBDIRS = $(PO_SUBDIR) libmenu desktop-directories layout util ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} diff --git a/configure.ac b/configure.ac index 1a3713e..f6c2a8f 100644 --- a/configure.ac +++ b/configure.ac @@ -24,9 +24,9 @@ MATE_COMPILE_WARNINGS LIB_MENU_LT_VERSION=6:9:4 AC_SUBST(LIB_MENU_LT_VERSION) -AM_GNU_GETTEXT_VERSION([0.19.8]) -AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8]) AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.19.8]) +AM_CONDITIONAL([USE_NLS], [test "x${USE_NLS}" = "xyes"]) GETTEXT_PACKAGE=AC_PACKAGE_NAME AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Name of default gettext domain]) @@ -103,5 +103,6 @@ echo " Turn on debugging: ${ax_enable_debug} Build introspection support: ${found_introspection} + Native Language support: ${USE_NLS} " diff --git a/desktop-directories/Makefile.am b/desktop-directories/Makefile.am index d3f8cb4..b09d2ee 100644 --- a/desktop-directories/Makefile.am +++ b/desktop-directories/Makefile.am @@ -30,7 +30,11 @@ directory_in_files = \ directory_DATA = $(directory_in_files:.directory.in=.directory) %.directory: %.directory.in +if USE_NLS $(AM_V_GEN) $(MSGFMT) --desktop --keyword= --keyword=Name --keyword=Description --template $< -d $(top_srcdir)/po -o $@ +else + $(AM_V_GEN) cp $< $@ +endif EXTRA_DIST= $(directory_in_files) diff --git a/po/POTFILES.in b/po/POTFILES.in index e5fdbda..8bea406 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,3 +21,4 @@ desktop-directories/mate-utility.directory.in desktop-directories/mate-menu-applications.directory.in desktop-directories/mate-menu-system.directory.in desktop-directories/mate-other.directory.in +util/test-menu-spec.c diff --git a/util/test-menu-spec.c b/util/test-menu-spec.c index 2b742fc..9de1ab6 100644 --- a/util/test-menu-spec.c +++ b/util/test-menu-spec.c @@ -19,7 +19,9 @@ #include #include +#ifdef ENABLE_NLS #include +#endif #include "matemenu-tree.h" @@ -202,7 +204,13 @@ main (int argc, char **argv) MateMenuTreeFlags flags; GError *error = NULL; +#ifdef ENABLE_NLS setlocale(LC_ALL, ""); + bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); +#endif /* ENABLE_NLS */ + options_context = g_option_context_new(_("- test MATE's implementation of the Desktop Menu Specification")); g_option_context_add_main_entries(options_context, options, GETTEXT_PACKAGE); g_option_context_parse(options_context, &argc, &argv, NULL); -- cgit v1.2.1