19#define _LIBGETTEXT_H 1
30#ifdef DEFAULT_TEXT_DOMAIN
32#define gettext(Msgid) \
33 dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
35#define ngettext(Msgid1, Msgid2, N) \
36 dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
54#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
56#if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
67#define gettext(Msgid) ((const char *) (Msgid))
69#define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
71#define dcgettext(Domainname, Msgid, Category) \
72 ((void) (Category), dgettext (Domainname, Msgid))
74#define ngettext(Msgid1, Msgid2, N) \
76 ? ((void) (Msgid2), (const char *) (Msgid1)) \
77 : ((void) (Msgid1), (const char *) (Msgid2)))
79#define dngettext(Domainname, Msgid1, Msgid2, N) \
80 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
82#define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
83 ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
85#define textdomain(Domainname) ((const char *) (Domainname))
87#define bindtextdomain(Domainname, Dirname) \
88 ((void) (Domainname), (const char *) (Dirname))
89#undef bind_textdomain_codeset
90#define bind_textdomain_codeset(Domainname, Codeset) \
91 ((void) (Domainname), (const char *) (Codeset))
96#ifdef GNULIB_defined_setlocale
98#define setlocale rpl_setlocale
108#define gettext_noop(String) String
111#define GETTEXT_CONTEXT_GLUE "\004"
117#ifdef DEFAULT_TEXT_DOMAIN
118#define pgettext(Msgctxt, Msgid) \
119 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
121#define pgettext(Msgctxt, Msgid) \
122 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
124#define dpgettext(Domainname, Msgctxt, Msgid) \
125 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
126#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
127 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
128#ifdef DEFAULT_TEXT_DOMAIN
129#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
130 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
132#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
133 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
135#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
136 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
137#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
138 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
148pgettext_aux (
const char *domain,
149 const char *msg_ctxt_id,
const char *msgid,
int category)
151 const char *translation = dcgettext (domain, msg_ctxt_id, category);
152 if (translation == msg_ctxt_id)
166npgettext_aux (
const char *domain,
167 const char *msg_ctxt_id,
const char *msgid,
168 const char *msgid_plural,
unsigned long int n,
int category)
170 const char *translation =
171 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
172 if (translation == msg_ctxt_id || translation == msgid_plural)
173 return (n == 1 ? msgid : msgid_plural);
184#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
186#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
188#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
191#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
195#define pgettext_expr(Msgctxt, Msgid) \
196 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
197#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
198 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
208dcpgettext_expr (
const char *domain,
209 const char *msgctxt,
const char *msgid,
int category)
211 size_t msgctxt_len = strlen (msgctxt) + 1;
212 size_t msgid_len = strlen (msgid) + 1;
213 const char *translation;
214#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
215 char msg_ctxt_id[msgctxt_len + msgid_len];
219 (msgctxt_len + msgid_len <=
sizeof (buf)
220 ? buf : (
char *) malloc (msgctxt_len + msgid_len));
221 if (msg_ctxt_id != NULL)
224 int found_translation;
225 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
226 msg_ctxt_id[msgctxt_len - 1] =
'\004';
227 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
228 translation = dcgettext (domain, msg_ctxt_id, category);
229 found_translation = (translation != msg_ctxt_id);
230#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
231 if (msg_ctxt_id != buf)
234 if (found_translation)
240#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
241 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
242#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
243 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
253dcnpgettext_expr (
const char *domain,
254 const char *msgctxt,
const char *msgid,
255 const char *msgid_plural,
unsigned long int n,
int category)
257 size_t msgctxt_len = strlen (msgctxt) + 1;
258 size_t msgid_len = strlen (msgid) + 1;
259 const char *translation;
260#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
261 char msg_ctxt_id[msgctxt_len + msgid_len];
265 (msgctxt_len + msgid_len <=
sizeof (buf)
266 ? buf : (
char *) malloc (msgctxt_len + msgid_len));
267 if (msg_ctxt_id != NULL)
270 int found_translation;
271 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
272 msg_ctxt_id[msgctxt_len - 1] =
'\004';
273 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
274 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
275 found_translation = !(translation == msg_ctxt_id
276 || translation == msgid_plural);
277#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
278 if (msg_ctxt_id != buf)
281 if (found_translation)
284 return (n == 1 ? msgid : msgid_plural);