summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-10-17 12:50:48 +0000
committerBruno Haible <bruno@clisp.org>2006-10-17 12:50:48 +0000
commita6f8cadf086f4abeda879dd491e5da7dddb01d59 (patch)
tree0ec27302dc07a50b16b4b83ecc13dc0baace8cab
parentd4dbda64df423d3e5519b19eb5d6c26f98b222bf (diff)
downloadgnulib-a6f8cadf086f4abeda879dd491e5da7dddb01d59.tar.gz
Introduce DEFAULT_TEXT_DOMAIN.
-rw-r--r--ChangeLog5
-rw-r--r--lib/gettext.h30
2 files changed, 31 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3efa4c2ba3..4c829a49c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-17 Bruno Haible <bruno@clisp.org>
+
+ * lib/gettext.h (gettext, ngettext, pgettext, npgettext): Define
+ differently if DEFAULT_TEXT_DOMAIN is set.
+
2006-10-16 Bruno Haible <bruno@clisp.org>
* lib/clean-temp.c: Include fwriteerror.h.
diff --git a/lib/gettext.h b/lib/gettext.h
index deeaf7931e..70e2c1c267 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -24,6 +24,18 @@
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
#else
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
@@ -82,14 +94,24 @@
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
short and rarely need to change.
The letter 'p' stands for 'particular' or 'special'. */
-#define pgettext(Msgctxt, Msgid) \
- pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
#define dpgettext(Domainname, Msgctxt, Msgid) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
-#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
- npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \