20 #define _LIBGETTEXT_H 1
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) || _GLIBCXX_HAVE_LIBINTL_H
67 # define gettext(Msgid) ((const char *) (Msgid))
68 # define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
69 # define dcgettext(Domainname, Msgid, Category) \
70 ((void) (Category), dgettext (Domainname, Msgid))
71 # define ngettext(Msgid1, Msgid2, N) \
73 ? ((void) (Msgid2), (const char *) (Msgid1)) \
74 : ((void) (Msgid1), (const char *) (Msgid2)))
75 # define dngettext(Domainname, Msgid1, Msgid2, N) \
76 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
77 # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
78 ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
79 # define textdomain(Domainname) ((const char *) (Domainname))
80 # define bindtextdomain(Domainname, Dirname) \
81 ((void) (Domainname), (const char *) (Dirname))
82 # define bind_textdomain_codeset(Domainname, Codeset) \
83 ((void) (Domainname), (const char *) (Codeset))
94 #define gettext_noop(String) String
97 #define GETTEXT_CONTEXT_GLUE "\004"
103 #ifdef DEFAULT_TEXT_DOMAIN
104 # define pgettext(Msgctxt, Msgid) \
105 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
107 # define pgettext(Msgctxt, Msgid) \
108 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
110 #define dpgettext(Domainname, Msgctxt, Msgid) \
111 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
112 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
113 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
114 #ifdef DEFAULT_TEXT_DOMAIN
115 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
116 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
118 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
119 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
121 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
122 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
123 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
124 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
135 const char *msg_ctxt_id,
const char *msgid,
138 const char *translation =
dcgettext (domain, msg_ctxt_id, category);
139 if (translation == msg_ctxt_id)
154 const char *msg_ctxt_id,
const char *msgid,
155 const char *msgid_plural,
unsigned long int n,
158 const char *translation =
159 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
160 if (translation == msg_ctxt_id || translation == msgid_plural)
161 return (n == 1 ? msgid : msgid_plural);
172 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
173 (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined(__STRICT_ANSI__)))
175 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
179 #define pgettext_expr(Msgctxt, Msgid) \
180 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
181 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
182 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
193 const char *msgctxt,
const char *msgid,
196 size_t msgctxt_len = strlen (msgctxt) + 1;
197 size_t msgid_len = strlen (msgid) + 1;
198 const char *translation;
199 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
200 char msg_ctxt_id[msgctxt_len + msgid_len];
204 (msgctxt_len + msgid_len <=
sizeof (buf)
206 : (
char *) malloc (msgctxt_len + msgid_len));
207 if (msg_ctxt_id !=
NULL)
210 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
211 msg_ctxt_id[msgctxt_len - 1] =
'\004';
212 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
213 translation =
dcgettext (domain, msg_ctxt_id, category);
214 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
215 if (msg_ctxt_id != buf)
218 if (translation != msg_ctxt_id)
224 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
225 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
226 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
227 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
238 const char *msgctxt,
const char *msgid,
239 const char *msgid_plural,
unsigned long int n,
242 size_t msgctxt_len = strlen (msgctxt) + 1;
243 size_t msgid_len = strlen (msgid) + 1;
244 const char *translation;
245 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
246 char msg_ctxt_id[msgctxt_len + msgid_len];
250 (msgctxt_len + msgid_len <=
sizeof (buf)
252 : (
char *) malloc (msgctxt_len + msgid_len));
253 if (msg_ctxt_id !=
NULL)
256 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
257 msg_ctxt_id[msgctxt_len - 1] =
'\004';
258 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
259 translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
260 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
261 if (msg_ctxt_id != buf)
264 if (!(translation == msg_ctxt_id || translation == msgid_plural))
267 return (n == 1 ? msgid : msgid_plural);