Paul Eggert wrote on 2025-09-09:
> This is for GNU Diffutils, which is still using the old way
> of also translating Gnulib’s msgids.

For reference, your rationale was in
<https://lists.gnu.org/archive/html/bug-diffutils/2025-09/msg00012.html>.

> * lib/gettext.h (GNULIB_TEXT_DOMAIN): New macro.

While it's OK to define GNULIB_TEXT_DOMAIN in the 'gettext-h' module,
I can't agree to have it in gettext.h.

gettext.h originates from the GNU gettext package, and is installed
in a public location wherefrom packages can incorporate it. I guess
that 95% of such packages do so without using Gnulib. Therefore
defining GNULIB_TEXT_DOMAIN in gettext.h is "random" stuff for them.

It's better to define Gnulib-specific things in files that originate
in Gnulib, i.e. not in gettext.h.

I also considered the possibility of having two gettext.h files, one
in Gnulib that defines more things than the general one. But that
would lead to sync hassles (on top of the other not-so-ideal interactions
between Gnulib and gettext).

I'm therefore applying this patch:


2025-09-13  Bruno Haible  <[email protected]>

        gettext-h: Move fallback definition of GNULIB_TEXT_DOMAIN.
        * lib/gettext.h (GNULIB_TEXT_DOMAIN): Remove macro.
        * modules/gettext-h (configure.ac): Define it here instead.

diff --git a/lib/gettext.h b/lib/gettext.h
index 214a0022d8..fd6c62b7eb 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -347,11 +347,5 @@ dcnpgettext_expr (const char *domain,
   return (n == 1 ? msgid : msgid_plural);
 }
 
-/* The text domainname for Gnulib messages.  Ordinarily this is "gnulib",
-   but packages that do their own translations of Gnulib can use
-   something different by defining GNULIB_TEXT_DOMAIN early.  */
-#ifndef GNULIB_TEXT_DOMAIN
-# define GNULIB_TEXT_DOMAIN "gnulib"
-#endif
 
 #endif /* _LIBGETTEXT_H */
diff --git a/modules/gettext-h b/modules/gettext-h
index 05e39ed709..1820137422 100644
--- a/modules/gettext-h
+++ b/modules/gettext-h
@@ -11,6 +11,14 @@ vararrays
 configure.ac:
 AC_SUBST([LIBINTL])
 AC_SUBST([LTLIBINTL])
+AH_BOTTOM([
+/* The text domainname for Gnulib messages.  Ordinarily this is "gnulib",
+   but packages that do their own translations of Gnulib can use something
+   different by defining GNULIB_TEXT_DOMAIN in their config.h file.  */
+#ifndef GNULIB_TEXT_DOMAIN
+# define GNULIB_TEXT_DOMAIN/**/"gnulib"
+#endif
+])
 
 Makefile.am:
 lib_SOURCES += gettext.h




Reply via email to