config_host.mk.in               |    1 +
 configure.ac                    |   28 ++++++++++++++++------------
 unotools/Library_utl.mk         |    5 +++++
 unotools/source/i18n/resmgr.cxx |    4 ++--
 4 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 7f5995113eb9add0e6bf7e009dd166fbbc6037a2
Author:     Andras Timar <[email protected]>
AuthorDate: Thu Feb 19 11:00:54 2026 +0100
Commit:     Andras Timar <[email protected]>
CommitDate: Thu Feb 19 16:04:14 2026 +0100

    libintl is not a runtime requirement for LOKit builds
    
    The bindtextdomain() / bind_textdomain_codeset() calls in
    unotools/source/i18n/resmgr.cxx exist solely to register .mo file
    paths with the system gettext so that GTK's internal dgettext() can
    find them for native dialogs (tdf#131069, tdf#119929).
    
    LOKit never uses GTK dialogs -- all translations go through
    Boost.Locale which has its own built-in .mo parser and does not call
    libintl. Therefore libintl is dispensable for LOKit.
    
    Change-Id: I4d6b95758867e56c72fa1cb7d960e55e4d1e49a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199707
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/config_host.mk.in b/config_host.mk.in
index 48cf25315c6a..0f242baf106e 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -422,6 +422,7 @@ export LIBEXTTEXTCAT_LIBS=$(gb_SPACE)@LIBEXTTEXTCAT_LIBS@
 export LIBFONTS_JAR=@LIBFONTS_JAR@
 export LIBFORMULA_JAR=@LIBFORMULA_JAR@
 export LIBINTL_LIBS=$(gb_SPACE)@LIBINTL_LIBS@
+export USE_LIBINTL=$(gb_SPACE)@USE_LIBINTL@
 export LIBJPEG_CFLAGS=$(gb_SPACE)@LIBJPEG_CFLAGS@
 export LIBJPEG_LIBS=$(gb_SPACE)@LIBJPEG_LIBS@
 export LIBLANGTAG_CFLAGS=$(gb_SPACE)@LIBLANGTAG_CFLAGS@
diff --git a/configure.ac b/configure.ac
index 100636d46c4e..dd6014684dd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1477,18 +1477,6 @@ if test "$usable_dlapi" != no; then
 fi
 AC_SUBST(UNIX_DLAPI_LIBS)
 
-# Check if libintl is needed (musl libc provides a stub bindtextdomain in libc,
-# but <libintl.h> from gettext-dev redefines it to libintl_bindtextdomain which
-# only exists in libintl.so)
-LIBINTL_LIBS=
-if test "$_os" = "Linux"; then
-    save_LIBS="$LIBS"
-    AC_SEARCH_LIBS([libintl_bindtextdomain], [intl],
-        [case "$ac_cv_search_libintl_bindtextdomain" in -l*) 
LIBINTL_LIBS="$ac_cv_search_libintl_bindtextdomain";; esac])
-    LIBS="$save_LIBS"
-fi
-AC_SUBST(LIBINTL_LIBS)
-
 # Check for a (GNU) backtrace implementation
 AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)])
 AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)])
@@ -12650,6 +12638,22 @@ fi
 AC_SUBST(GTK4_LIBS)
 AC_SUBST(GTK4_CFLAGS)
 
+# libintl is only needed to register .mo files with bindtextdomain so that GTK
+# dialogs can find translations. Without GTK there is no point.
+# On musl, <libintl.h> from gettext-dev redefines bindtextdomain to
+# libintl_bindtextdomain which requires linking -lintl; on glibc it is in libc.
+LIBINTL_LIBS=
+USE_LIBINTL=
+if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE" -o 
"$ENABLE_GTK4" = "TRUE"; then
+    USE_LIBINTL=TRUE
+    save_LIBS="$LIBS"
+    AC_SEARCH_LIBS([libintl_bindtextdomain], [intl],
+        [case "$ac_cv_search_libintl_bindtextdomain" in -l*) 
LIBINTL_LIBS="$ac_cv_search_libintl_bindtextdomain";; esac])
+    LIBS="$save_LIBS"
+fi
+AC_SUBST(LIBINTL_LIBS)
+AC_SUBST(USE_LIBINTL)
+
 if test "$enable_introspection" = yes; then
     if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
         GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk
index e5a8bf725f76..478da87223a6 100644
--- a/unotools/Library_utl.mk
+++ b/unotools/Library_utl.mk
@@ -16,11 +16,16 @@ $(eval $(call gb_Library_use_externals,utl,\
        boost_locale \
 ))
 
+ifeq ($(USE_LIBINTL),TRUE)
+$(eval $(call gb_Library_add_defs,utl,\
+       -DHAVE_LIBINTL \
+))
 ifneq ($(LIBINTL_LIBS),)
 $(eval $(call gb_Library_add_libs,utl,\
        $(LIBINTL_LIBS) \
 ))
 endif
+endif
 
 $(eval $(call gb_Library_use_custom_headers,utl,\
  officecfg/registry \
diff --git a/unotools/source/i18n/resmgr.cxx b/unotools/source/i18n/resmgr.cxx
index f93e943b628a..34ed5a9dd031 100644
--- a/unotools/source/i18n/resmgr.cxx
+++ b/unotools/source/i18n/resmgr.cxx
@@ -36,7 +36,7 @@
 
 #include <string.h>
 #include <stdio.h>
-#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && 
!defined EMSCRIPTEN
+#ifdef HAVE_LIBINTL
 #   include <libintl.h>
 #endif
 
@@ -142,7 +142,7 @@ namespace Translate
         OString sPath(OUStringToOString(path, eEncoding));
 #endif
         gen.add_messages_path(std::string(sPath));
-#if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID && 
!defined EMSCRIPTEN
+#ifdef HAVE_LIBINTL
         // allow gettext to find these .mo files e.g. so gtk dialogs can use 
them
         bindtextdomain(aPrefixName.data(), sPath.getStr());
         // tdf#131069 gtk, and anything sane, always wants utf-8 strings as 
output

Reply via email to