> 2024-12-08  Bruno Haible  <br...@clisp.org>
> 
>       Use the translation domain "gnulib".

There are some more ad-hoc uses of gettext(). Handled through this series
of patches.


2024-12-09  Bruno Haible  <br...@clisp.org>

        xstrtol-error: Use the translation domain "gnulib".
        * lib/xstrtol-error.c (_): New macro.
        (xstrtol_error): Use dgettext() instead of gettext().
        * modules/xstrtol-error (Depends-on): Add gnulib-i18n.

        xprintf: Use the translation domain "gnulib".
        * lib/xprintf.c (_): New macro.
        (xvprintf, xvfprintf): Use it instead of gettext().
        * modules/xprintf (Depends-on): Add gnulib-i18n.

        unicodeio: Use the translation domain "gnulib".
        * lib/unicodeio.h (unicode_to_mb): Clarify that the message passed to
        the failure callback may already be localized.
        * lib/unicodeio.c (unicode_to_mb): For the messages defined in this
        file, use the translation domain "gnulib".

        file-type: Use the translation domain "gnulib".
        * lib/file-type.c (file_type): Use the translation domain "gnulib".
        * modules/file-type (Depends-on): Add gnulib-i18n.

        argmatch: Use the translation domain "gnulib".
        * lib/argmatch.h (ARGMATCH_DEFINE_GROUP): Use translation domain
        "gnulib" for the literal string here.

>From f6a229c2a77a33fdc853285ab2ec219eb7f5a99d Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 9 Dec 2024 13:26:51 +0100
Subject: [PATCH 1/5] argmatch: Use the translation domain "gnulib".

* lib/argmatch.h (ARGMATCH_DEFINE_GROUP): Use translation domain
"gnulib" for the literal string here.
---
 ChangeLog      | 6 ++++++
 lib/argmatch.h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9d0e2f4556..9a114d53ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-09  Bruno Haible  <br...@clisp.org>
+
+	argmatch: Use the translation domain "gnulib".
+	* lib/argmatch.h (ARGMATCH_DEFINE_GROUP): Use translation domain
+	"gnulib" for the literal string here.
+
 2024-12-09  Bruno Haible  <br...@clisp.org>
 
 	Localizations: Fix omissions from the POT file.
diff --git a/lib/argmatch.h b/lib/argmatch.h
index ca60dfe1ce..913c5617d9 100644
--- a/lib/argmatch.h
+++ b/lib/argmatch.h
@@ -239,7 +239,7 @@ char const *argmatch_to_argument (void const *value,
                                                                         \
     /* Try to put synonyms on the same line.  Synonyms are expected     \
        to follow each other. */                                         \
-    fputs (gettext ("Valid arguments are:"), out);                      \
+    fputs (dgettext ("gnulib", "Valid arguments are:"), out);           \
     for (int i = 0; g->args[i].arg; i++)                                \
       if (i == 0                                                        \
           || memcmp (&g->args[i-1].val, &g->args[i].val, size))         \
-- 
2.34.1

>From b41239c53e6f2c4540a8d16f71153d57e96dd836 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 9 Dec 2024 13:28:43 +0100
Subject: [PATCH 2/5] file-type: Use the translation domain "gnulib".

* lib/file-type.c (file_type): Use the translation domain "gnulib".
* modules/file-type (Depends-on): Add gnulib-i18n.
---
 ChangeLog         | 4 ++++
 lib/file-type.c   | 2 +-
 modules/file-type | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9a114d53ec..f05fb1e315 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-12-09  Bruno Haible  <br...@clisp.org>
 
+	file-type: Use the translation domain "gnulib".
+	* lib/file-type.c (file_type): Use the translation domain "gnulib".
+	* modules/file-type (Depends-on): Add gnulib-i18n.
+
 	argmatch: Use the translation domain "gnulib".
 	* lib/argmatch.h (ARGMATCH_DEFINE_GROUP): Use translation domain
 	"gnulib" for the literal string here.
diff --git a/lib/file-type.c b/lib/file-type.c
index 657ca5c7f9..b605e79c16 100644
--- a/lib/file-type.c
+++ b/lib/file-type.c
@@ -27,5 +27,5 @@
 char const *
 file_type (struct stat const *st)
 {
-  return gettext (c_file_type (st));
+  return dgettext ("gnulib", c_file_type (st));
 }
diff --git a/modules/file-type b/modules/file-type
index c2bc9f59ba..5f472e3c1a 100644
--- a/modules/file-type
+++ b/modules/file-type
@@ -8,6 +8,7 @@ lib/file-type.c
 Depends-on:
 c-file-type
 gettext-h
+gnulib-i18n
 sys_stat
 
 configure.ac:
-- 
2.34.1

>From 22fb9dcebb1249d1ec7cf5e9b62c1b95b1f25254 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 9 Dec 2024 13:31:23 +0100
Subject: [PATCH 3/5] unicodeio: Use the translation domain "gnulib".

* lib/unicodeio.h (unicode_to_mb): Clarify that the message passed to
the failure callback may already be localized.
* lib/unicodeio.c (unicode_to_mb): For the messages defined in this
file, use the translation domain "gnulib".
---
 ChangeLog       | 6 ++++++
 lib/unicodeio.c | 8 ++++----
 lib/unicodeio.h | 2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f05fb1e315..64c1723734 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2024-12-09  Bruno Haible  <br...@clisp.org>
 
+	unicodeio: Use the translation domain "gnulib".
+	* lib/unicodeio.h (unicode_to_mb): Clarify that the message passed to
+	the failure callback may already be localized.
+	* lib/unicodeio.c (unicode_to_mb): For the messages defined in this
+	file, use the translation domain "gnulib".
+
 	file-type: Use the translation domain "gnulib".
 	* lib/file-type.c (file_type): Use the translation domain "gnulib".
 	* modules/file-type (Depends-on): Add gnulib-i18n.
diff --git a/lib/unicodeio.c b/lib/unicodeio.c
index 1c7503ad58..876fb353d0 100644
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -57,7 +57,7 @@
 /* Converts the Unicode character CODE to its multibyte representation
    in the current locale and calls the SUCCESS callback on the resulting
    byte sequence.  If an error occurs, invokes the FAILURE callback instead,
-   passing it CODE and an English error string.
+   passing it CODE and an English (or already localized) error string.
    Returns whatever the callback returned.
    Assumes that the locale doesn't change between two calls.  */
 long
@@ -99,16 +99,16 @@ unicode_to_mb (unsigned int code,
     {
 #if HAVE_ICONV
       if (utf8_to_local == (iconv_t)(-1))
-        return failure (code, N_("iconv function not usable"), callback_arg);
+        return failure (code, _("iconv function not usable"), callback_arg);
 #else
-      return failure (code, N_("iconv function not available"), callback_arg);
+      return failure (code, _("iconv function not available"), callback_arg);
 #endif
     }
 
   /* Convert the character to UTF-8.  */
   count = u8_uctomb ((unsigned char *) inbuf, code, sizeof (inbuf));
   if (count < 0)
-    return failure (code, N_("character out of range"), callback_arg);
+    return failure (code, _("character out of range"), callback_arg);
 
 #if HAVE_ICONV
   if (!is_utf8)
diff --git a/lib/unicodeio.h b/lib/unicodeio.h
index 0db1d35f52..a5115885b6 100644
--- a/lib/unicodeio.h
+++ b/lib/unicodeio.h
@@ -29,7 +29,7 @@ extern "C" {
 /* Converts the Unicode character CODE to its multibyte representation
    in the current locale and calls the SUCCESS callback on the resulting
    byte sequence.  If an error occurs, invokes the FAILURE callback instead,
-   passing it CODE and an English error string.
+   passing it CODE and an English (or already localized) error string.
    Returns whatever the callback returned.
    Assumes that the locale doesn't change between two calls.  */
 extern long unicode_to_mb (unsigned int code,
-- 
2.34.1

>From 6a6a72cb86a5178ba2a0cbf6c7e7e112df6036e2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 9 Dec 2024 13:33:15 +0100
Subject: [PATCH 4/5] xprintf: Use the translation domain "gnulib".

* lib/xprintf.c (_): New macro.
(xvprintf, xvfprintf): Use it instead of gettext().
* modules/xprintf (Depends-on): Add gnulib-i18n.
---
 ChangeLog       | 5 +++++
 lib/xprintf.c   | 6 ++++--
 modules/xprintf | 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 64c1723734..4fb012ec80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2024-12-09  Bruno Haible  <br...@clisp.org>
 
+	xprintf: Use the translation domain "gnulib".
+	* lib/xprintf.c (_): New macro.
+	(xvprintf, xvfprintf): Use it instead of gettext().
+	* modules/xprintf (Depends-on): Add gnulib-i18n.
+
 	unicodeio: Use the translation domain "gnulib".
 	* lib/unicodeio.h (unicode_to_mb): Clarify that the message passed to
 	the failure callback may already be localized.
diff --git a/lib/xprintf.c b/lib/xprintf.c
index 1957131f49..732bbea407 100644
--- a/lib/xprintf.c
+++ b/lib/xprintf.c
@@ -24,6 +24,8 @@
 #include "exitfail.h"
 #include "gettext.h"
 
+#define _(msgid) dgettext ("gnulib", msgid)
+
 /* written by Jim Meyering */
 
 /* Just like printf, but call error if it fails without setting the
@@ -47,7 +49,7 @@ xvprintf (char const *restrict format, va_list args)
 {
   int retval = vprintf (format, args);
   if (retval < 0 && ! ferror (stdout))
-    error (exit_failure, errno, gettext ("cannot perform formatted output"));
+    error (exit_failure, errno, _("cannot perform formatted output"));
 
   return retval;
 }
@@ -73,7 +75,7 @@ xvfprintf (FILE *restrict stream, char const *restrict format, va_list args)
 {
   int retval = vfprintf (stream, format, args);
   if (retval < 0 && ! ferror (stream))
-    error (exit_failure, errno, gettext ("cannot perform formatted output"));
+    error (exit_failure, errno, _("cannot perform formatted output"));
 
   return retval;
 }
diff --git a/modules/xprintf b/modules/xprintf
index f4942cea87..79c82d9168 100644
--- a/modules/xprintf
+++ b/modules/xprintf
@@ -10,6 +10,7 @@ stdio
 error
 exitfail
 gettext-h
+gnulib-i18n
 stdarg
 
 configure.ac:
-- 
2.34.1

>From 03326a89415e32ce1a919336abb8730295b8703e Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 9 Dec 2024 13:34:51 +0100
Subject: [PATCH 5/5] xstrtol-error: Use the translation domain "gnulib".

* lib/xstrtol-error.c (_): New macro.
(xstrtol_error): Use dgettext() instead of gettext().
* modules/xstrtol-error (Depends-on): Add gnulib-i18n.
---
 ChangeLog             | 5 +++++
 lib/xstrtol-error.c   | 3 ++-
 modules/xstrtol-error | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 4fb012ec80..54546f10c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2024-12-09  Bruno Haible  <br...@clisp.org>
 
+	xstrtol-error: Use the translation domain "gnulib".
+	* lib/xstrtol-error.c (_): New macro.
+	(xstrtol_error): Use dgettext() instead of gettext().
+	* modules/xstrtol-error (Depends-on): Add gnulib-i18n.
+
 	xprintf: Use the translation domain "gnulib".
 	* lib/xprintf.c (_): New macro.
 	(xvprintf, xvfprintf): Use it instead of gettext().
diff --git a/lib/xstrtol-error.c b/lib/xstrtol-error.c
index 16d817a467..68c30d4698 100644
--- a/lib/xstrtol-error.c
+++ b/lib/xstrtol-error.c
@@ -25,6 +25,7 @@
 #include "exitfail.h"
 #include "gettext.h"
 
+#define _(msgid) dgettext ("gnulib", msgid)
 #define N_(msgid) msgid
 
 /* Report an error for an invalid integer in an option argument.
@@ -83,7 +84,7 @@ xstrtol_error (enum strtol_error err,
   else
     option = long_options[opt_idx].name;
 
-  error (exit_status, 0, gettext (msgid), hyphens, option, arg);
+  error (exit_status, 0, dgettext ("gnulib", msgid), hyphens, option, arg);
 }
 
 /* Like xstrtol_error, except exit with a failure status.  */
diff --git a/modules/xstrtol-error b/modules/xstrtol-error
index 9c3da2a5ab..60319acc7f 100644
--- a/modules/xstrtol-error
+++ b/modules/xstrtol-error
@@ -11,6 +11,7 @@ error
 exitfail
 getopt-gnu
 gettext-h
+gnulib-i18n
 
 configure.ac:
 
-- 
2.34.1

Reply via email to