18#define _LIBGETTEXT_H 1
23#if defined ENABLE_NLS && ENABLE_NLS
31# ifdef DEFAULT_TEXT_DOMAIN
33# define gettext(Msgid) \
34 dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
36# define ngettext(Msgid1, Msgid2, N) \
37 dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
55# if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
57# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
68# define gettext(Msgid) ((const char *) (Msgid))
70# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
72# define dcgettext(Domainname, Msgid, Category) \
73 ((void) (Category), dgettext (Domainname, Msgid))
75# define ngettext(Msgid1, Msgid2, N) \
77 ? ((void) (Msgid2), (const char *) (Msgid1)) \
78 : ((void) (Msgid1), (const char *) (Msgid2)))
80# define dngettext(Domainname, Msgid1, Msgid2, N) \
81 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
83# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
84 ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
86# define textdomain(Domainname) ((const char *) (Domainname))
88# define bindtextdomain(Domainname, Dirname) \
89 ((void) (Domainname), (const char *) (Dirname))
90# undef bind_textdomain_codeset
91# define bind_textdomain_codeset(Domainname, Codeset) \
92 ((void) (Domainname), (const char *) (Codeset))
98#ifdef GNULIB_defined_setlocale
100# define setlocale rpl_setlocale
111#define gettext_noop(String) String
115#define GETTEXT_CONTEXT_GLUE "\004"
124#ifdef DEFAULT_TEXT_DOMAIN
125# define pgettext(Msgctxt, Msgid) \
126 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
128# define pgettext(Msgctxt, Msgid) \
129 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
131#define dpgettext(Domainname, Msgctxt, Msgid) \
132 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
133#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
134 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
135#ifdef DEFAULT_TEXT_DOMAIN
136# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
137 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
139# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
140 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
142#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
143 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
144#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
145 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
147#if defined __GNUC__ || defined __clang__
155pgettext_aux (
const char *domain,
156 const char *msg_ctxt_id,
const char *msgid,
159 const char *translation = dcgettext (domain, msg_ctxt_id, category);
160 if (translation == msg_ctxt_id)
166#if defined __GNUC__ || defined __clang__
174npgettext_aux (
const char *domain,
175 const char *msg_ctxt_id,
const char *msgid,
176 const char *msgid_plural,
unsigned long int n,
179 const char *translation =
180 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
181 if (translation == msg_ctxt_id || translation == msgid_plural)
182 return (n == 1 ? msgid : msgid_plural);
200#if (!defined GNULIB_NO_VLA \
201 && (((__GNUC__ >= 3 || defined __clang__) \
202 && !defined __STRICT_ANSI__ && !defined __cplusplus) \
205# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
207# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
210#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
214#define pgettext_expr(Msgctxt, Msgid) \
215 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
216#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
217 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
219#if defined __GNUC__ || defined __clang__
227dcpgettext_expr (
const char *domain,
228 const char *msgctxt,
const char *msgid,
231 size_t msgctxt_len = strlen (msgctxt) + 1;
232 size_t msgid_len = strlen (msgid) + 1;
233 const char *translation;
234#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
235 char msg_ctxt_id[msgctxt_len + msgid_len];
239 (msgctxt_len + msgid_len <=
sizeof (buf)
241 : (
char *) malloc (msgctxt_len + msgid_len));
242 if (msg_ctxt_id != NULL)
245 int found_translation;
246 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
247 msg_ctxt_id[msgctxt_len - 1] =
'\004';
248 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
249 translation = dcgettext (domain, msg_ctxt_id, category);
250 found_translation = (translation != msg_ctxt_id);
251#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
252 if (msg_ctxt_id != buf)
255 if (found_translation)
261#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
262 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
263#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
264 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
266#if defined __GNUC__ || defined __clang__
274dcnpgettext_expr (
const char *domain,
275 const char *msgctxt,
const char *msgid,
276 const char *msgid_plural,
unsigned long int n,
279 size_t msgctxt_len = strlen (msgctxt) + 1;
280 size_t msgid_len = strlen (msgid) + 1;
281 const char *translation;
282#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
283 char msg_ctxt_id[msgctxt_len + msgid_len];
287 (msgctxt_len + msgid_len <=
sizeof (buf)
289 : (
char *) malloc (msgctxt_len + msgid_len));
290 if (msg_ctxt_id != NULL)
293 int found_translation;
294 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
295 msg_ctxt_id[msgctxt_len - 1] =
'\004';
296 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
297 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
298 found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
299#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
300 if (msg_ctxt_id != buf)
303 if (found_translation)
306 return (n == 1 ? msgid : msgid_plural);