21#define _LIBGETTEXT_H 1
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)
56#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
58#if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
69#define gettext(Msgid) ((const char *) (Msgid))
71#define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
73#define dcgettext(Domainname, Msgid, Category) \
74 ((void) (Category), dgettext (Domainname, Msgid))
76#define ngettext(Msgid1, Msgid2, N) \
78 ? ((void) (Msgid2), (const char *) (Msgid1)) \
79 : ((void) (Msgid1), (const char *) (Msgid2)))
81#define dngettext(Domainname, Msgid1, Msgid2, N) \
82 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
84#define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
85 ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
87#define textdomain(Domainname) ((const char *) (Domainname))
89#define bindtextdomain(Domainname, Dirname) \
90 ((void) (Domainname), (const char *) (Dirname))
91#undef bind_textdomain_codeset
92#define bind_textdomain_codeset(Domainname, Codeset) \
93 ((void) (Domainname), (const char *) (Codeset))
104#define gettext_noop(String) String
107#define GETTEXT_CONTEXT_GLUE "\004"
113#ifdef DEFAULT_TEXT_DOMAIN
114#define pgettext(Msgctxt, Msgid) \
115 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
117#define pgettext(Msgctxt, Msgid) \
118 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
120#define dpgettext(Domainname, Msgctxt, Msgid) \
121 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
122#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
123 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
124#ifdef DEFAULT_TEXT_DOMAIN
125#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
126 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
128#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
129 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
131#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
132 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
133#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
134 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
143static const char *pgettext_aux(
const char *domain,
144 const char *msg_ctxt_id,
const char *msgid,
147 const char *translation = dcgettext(domain, msg_ctxt_id, category);
149 if (translation == msg_ctxt_id)
162static const char *npgettext_aux(
const char *domain,
163 const char *msg_ctxt_id,
const char *msgid,
164 const char *msgid_plural,
165 unsigned long int n,
int category)
167 const char *translation =
168 dcngettext(domain, msg_ctxt_id, msgid_plural, n, category);
169 if (translation == msg_ctxt_id || translation == msgid_plural)
170 return (n == 1 ? msgid : msgid_plural);
181#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
182 (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
185#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
189#define pgettext_expr(Msgctxt, Msgid) \
190 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
191#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
192 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
201static const char *dcpgettext_expr(
const char *domain,
202 const char *msgctxt,
const char *msgid,
205 size_t msgctxt_len = strlen(msgctxt) + 1;
206 size_t msgid_len = strlen(msgid) + 1;
207 const char *translation;
209#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
210 char msg_ctxt_id[msgctxt_len + msgid_len];
214 (msgctxt_len + msgid_len <=
sizeof(buf)
215 ? buf : (char *) malloc(msgctxt_len + msgid_len));
216 if (msg_ctxt_id != NULL)
219 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
220 msg_ctxt_id[msgctxt_len - 1] =
'\004';
221 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
222 translation = dcgettext(domain, msg_ctxt_id, category);
223#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
224 if (msg_ctxt_id != buf)
227 if (translation != msg_ctxt_id)
233#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
234 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
235#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
236 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
245static const char *dcnpgettext_expr(
const char *domain,
246 const char *msgctxt,
const char *msgid,
247 const char *msgid_plural,
248 unsigned long int n,
int category)
250 size_t msgctxt_len = strlen(msgctxt) + 1;
251 size_t msgid_len = strlen(msgid) + 1;
252 const char *translation;
254#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
255 char msg_ctxt_id[msgctxt_len + msgid_len];
259 (msgctxt_len + msgid_len <=
sizeof(buf)
260 ? buf : (char *) malloc(msgctxt_len + msgid_len));
261 if (msg_ctxt_id != NULL)
264 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
265 msg_ctxt_id[msgctxt_len - 1] =
'\004';
266 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
268 dcngettext(domain, msg_ctxt_id, msgid_plural, n,
270#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
271 if (msg_ctxt_id != buf)
275 (translation == msg_ctxt_id
276 || translation == msgid_plural))
279 return (n == 1 ? msgid : msgid_plural);