24#if defined(ENABLE_NLS)
32# ifdef DEFAULT_TEXT_DOMAIN
34# define gettext(Msgid) \
35 dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
37# define ngettext(Msgid1, Msgid2, N) \
38 dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
46#if defined(__cplusplus)
48# if defined(__GLIBC__)
49# if (__GLIBC__ >= 2) || defined(_GLIBCXX_HAVE_LIBINTL_H)
61# define gettext(Msgid) ((const char *) (Msgid))
62# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
63# define dcgettext(Domainname, Msgid, Category) \
64 ((void) (Category), dgettext (Domainname, Msgid))
65# define ngettext(Msgid1, Msgid2, N) \
67 ? ((void) (Msgid2), (const char *) (Msgid1)) \
68 : ((void) (Msgid1), (const char *) (Msgid2)))
69# define dngettext(Domainname, Msgid1, Msgid2, N) \
70 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
71# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
72 ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
73# define textdomain(Domainname) ((const char *) (Domainname))
74# define bindtextdomain(Domainname, Dirname) \
75 ((void) (Domainname), (const char *) (Dirname))
76# define bind_textdomain_codeset(Domainname, Codeset) \
77 ((void) (Domainname), (const char *) (Codeset))
88#define gettext_noop(String) String
91#define GETTEXT_CONTEXT_GLUE "\004"
97#ifdef DEFAULT_TEXT_DOMAIN
98# define pgettext(Msgctxt, Msgid) \
99 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
101# define pgettext(Msgctxt, Msgid) \
102 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
104#define dpgettext(Domainname, Msgctxt, Msgid) \
105 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
106#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
107 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
108#ifdef DEFAULT_TEXT_DOMAIN
109# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
110 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
112# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
113 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
115#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
116 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
117#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
118 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
122pgettext_aux (
const char *domain,
123 const char *msg_ctxt_id,
const char *msgid,
126 const char *translation = dcgettext (domain, msg_ctxt_id, category);
127 if (translation == msg_ctxt_id)
135npgettext_aux (
const char *domain,
136 const char *msg_ctxt_id,
const char *msgid,
137 const char *msgid_plural,
unsigned long int n,
140 const char *translation =
141 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
142 if (translation == msg_ctxt_id || translation == msgid_plural)
143 return (n == 1 ? msgid : msgid_plural);
155#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
157#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
161#define pgettext_expr(Msgctxt, Msgid) \
162 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
163#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
164 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
168dcpgettext_expr (
const char *domain,
169 const char *msgctxt,
const char *msgid,
172 size_t msgctxt_len = strlen (msgctxt) + 1;
173 size_t msgid_len = strlen (msgid) + 1;
174 const char *translation;
175#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
176 char msg_ctxt_id[msgctxt_len + msgid_len];
180 (msgctxt_len + msgid_len <=
sizeof (buf)
182 : (
char *) malloc (msgctxt_len + msgid_len));
183 if (msg_ctxt_id != NULL)
186 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
187 msg_ctxt_id[msgctxt_len - 1] =
'\004';
188 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
189 translation = dcgettext (domain, msg_ctxt_id, category);
190#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
191 if (msg_ctxt_id != buf)
194 if (translation != msg_ctxt_id)
200#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
201 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
202#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
203 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
207dcnpgettext_expr (
const char *domain,
208 const char *msgctxt,
const char *msgid,
209 const char *msgid_plural,
unsigned long int n,
212 size_t msgctxt_len = strlen (msgctxt) + 1;
213 size_t msgid_len = strlen (msgid) + 1;
214 const char *translation;
215#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
216 char msg_ctxt_id[msgctxt_len + msgid_len];
220 (msgctxt_len + msgid_len <=
sizeof (buf)
222 : (
char *) malloc (msgctxt_len + msgid_len));
223 if (msg_ctxt_id != NULL)
226 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
227 msg_ctxt_id[msgctxt_len - 1] =
'\004';
228 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
229 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
230#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
231 if (msg_ctxt_id != buf)
234 if (!(translation == msg_ctxt_id || translation == msgid_plural))
237 return (n == 1 ? msgid : msgid_plural);
240#define _(String) gettext(String)
241#define N_(String) gettext_noop(String)