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)
56 #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
58 # if defined(__GLIBC__)
59 # if (__GLIBC__ >= 2) || defined(_GLIBCXX_HAVE_LIBINTL_H)
71 # define gettext(Msgid) ((const char *) (Msgid))
72 # define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
73 # define dcgettext(Domainname, Msgid, Category) \
74 ((void) (Category), dgettext (Domainname, Msgid))
75 # define ngettext(Msgid1, Msgid2, N) \
77 ? ((void) (Msgid2), (const char *) (Msgid1)) \
78 : ((void) (Msgid1), (const char *) (Msgid2)))
79 # define dngettext(Domainname, Msgid1, Msgid2, N) \
80 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
81 # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
82 ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
83 # define textdomain(Domainname) ((const char *) (Domainname))
84 # define bindtextdomain(Domainname, Dirname) \
85 ((void) (Domainname), (const char *) (Dirname))
86 # define bind_textdomain_codeset(Domainname, Codeset) \
87 ((void) (Domainname), (const char *) (Codeset))
98 #define gettext_noop(String) String
101 #define GETTEXT_CONTEXT_GLUE "\004"
107 #ifdef DEFAULT_TEXT_DOMAIN
108 # define pgettext(Msgctxt, Msgid) \
109 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
111 # define pgettext(Msgctxt, Msgid) \
112 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
114 #define dpgettext(Domainname, Msgctxt, Msgid) \
115 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
116 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
117 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
118 #ifdef DEFAULT_TEXT_DOMAIN
119 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
120 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
122 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
123 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
125 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
126 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
127 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
128 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
138 pgettext_aux (
const char *domain,
139 const char *msg_ctxt_id,
const char *msgid,
142 const char *translation = dcgettext (domain, msg_ctxt_id, category);
143 if (translation == msg_ctxt_id)
157 npgettext_aux (
const char *domain,
158 const char *msg_ctxt_id,
const char *msgid,
159 const char *msgid_plural,
unsigned long int n,
162 const char *translation =
163 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
164 if (translation == msg_ctxt_id || translation == msgid_plural)
165 return (n == 1 ? msgid : msgid_plural);
177 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
179 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
183 #define pgettext_expr(Msgctxt, Msgid) \
184 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
185 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
186 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
196 dcpgettext_expr (
const char *domain,
197 const char *msgctxt,
const char *msgid,
200 size_t msgctxt_len = strlen (msgctxt) + 1;
201 size_t msgid_len = strlen (msgid) + 1;
202 const char *translation;
203 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
204 char msg_ctxt_id[msgctxt_len + msgid_len];
208 (msgctxt_len + msgid_len <=
sizeof (buf)
210 : (
char *) malloc (msgctxt_len + msgid_len));
211 if (msg_ctxt_id != NULL)
214 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
215 msg_ctxt_id[msgctxt_len - 1] =
'\004';
216 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
217 translation = dcgettext (domain, msg_ctxt_id, category);
218 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
219 if (msg_ctxt_id != buf)
222 if (translation != msg_ctxt_id)
228 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
229 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
230 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
231 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
241 dcnpgettext_expr (
const char *domain,
242 const char *msgctxt,
const char *msgid,
243 const char *msgid_plural,
unsigned long int n,
246 size_t msgctxt_len = strlen (msgctxt) + 1;
247 size_t msgid_len = strlen (msgid) + 1;
248 const char *translation;
249 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
250 char msg_ctxt_id[msgctxt_len + msgid_len];
254 (msgctxt_len + msgid_len <=
sizeof (buf)
256 : (
char *) malloc (msgctxt_len + msgid_len));
257 if (msg_ctxt_id != NULL)
260 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
261 msg_ctxt_id[msgctxt_len - 1] =
'\004';
262 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
263 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
264 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
265 if (msg_ctxt_id != buf)
268 if (!(translation == msg_ctxt_id || translation == msgid_plural))
271 return (n == 1 ? msgid : msgid_plural);
274 #define _(String) gettext(String)
275 #define N_(String) gettext_noop(String)