20 #define _LIBGETTEXT_H 1
31 #ifdef DEFAULT_TEXT_DOMAIN
33 #define gettext(Msgid) dgettext(DEFAULT_TEXT_DOMAIN, Msgid)
35 #define ngettext(Msgid1, Msgid2, N) dngettext(DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
53 #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
55 #if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
66 #define gettext(Msgid) ((const char*)(Msgid))
68 #define dgettext(Domainname, Msgid) ((void)(Domainname), gettext(Msgid))
70 #define dcgettext(Domainname, Msgid, Category) ((void)(Category), dgettext(Domainname, Msgid))
72 #define ngettext(Msgid1, Msgid2, N) \
73 ((N) == 1 ? ((void)(Msgid2), (const char*)(Msgid1)) : ((void)(Msgid1), (const char*)(Msgid2)))
75 #define dngettext(Domainname, Msgid1, Msgid2, N) ((void)(Domainname), ngettext(Msgid1, Msgid2, N))
77 #define dcngettext(Domainname, Msgid1, Msgid2, N, Category) ((void)(Category), dngettext(Domainname, Msgid1, Msgid2, N))
79 #define textdomain(Domainname) ((const char*)(Domainname))
81 #define bindtextdomain(Domainname, Dirname) ((void)(Domainname), (const char*)(Dirname))
82 #undef bind_textdomain_codeset
83 #define bind_textdomain_codeset(Domainname, Codeset) ((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) pgettext_aux(NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
109 #define dpgettext(Domainname, Msgctxt, Msgid) \
110 pgettext_aux(Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
111 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
112 pgettext_aux(Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
113 #ifdef DEFAULT_TEXT_DOMAIN
114 #define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
115 npgettext_aux(DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
117 #define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
118 npgettext_aux(NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
120 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
121 npgettext_aux(Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
122 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
123 npgettext_aux(Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
133 pgettext_aux(
const char* domain,
const char* msg_ctxt_id,
const char* msgid,
int category) {
134 const char* translation = dcgettext(domain, msg_ctxt_id, category);
135 if (translation == msg_ctxt_id)
150 const char* domain,
const char* msg_ctxt_id,
const char* msgid,
const char* msgid_plural,
unsigned long int n,
153 const char* translation = dcngettext(domain, msg_ctxt_id, msgid_plural, n, category);
154 if (translation == msg_ctxt_id || translation == msgid_plural)
155 return (n == 1 ? msgid : msgid_plural);
166 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
167 (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) )
169 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
173 #define pgettext_expr(Msgctxt, Msgid) dcpgettext_expr(NULL, Msgctxt, Msgid, LC_MESSAGES)
174 #define dpgettext_expr(Domainname, Msgctxt, Msgid) dcpgettext_expr(Domainname, Msgctxt, Msgid, LC_MESSAGES)
184 dcpgettext_expr(
const char* domain,
const char* msgctxt,
const char* msgid,
int category) {
185 size_t msgctxt_len = strlen(msgctxt) + 1;
186 size_t msgid_len = strlen(msgid) + 1;
187 const char* translation;
188 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
189 char msg_ctxt_id[msgctxt_len + msgid_len];
192 char* msg_ctxt_id = (msgctxt_len + msgid_len <=
sizeof(buf) ? buf : (
char*)malloc(msgctxt_len + msgid_len));
193 if (msg_ctxt_id != NULL)
196 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
197 msg_ctxt_id[msgctxt_len - 1] =
'\004';
198 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
199 translation = dcgettext(domain, msg_ctxt_id, category);
200 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
201 if (msg_ctxt_id != buf)
204 if (translation != msg_ctxt_id)
210 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
211 dcnpgettext_expr(NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
212 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
213 dcnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
224 const char* domain,
const char* msgctxt,
const char* msgid,
const char* msgid_plural,
unsigned long int n,
227 size_t msgctxt_len = strlen(msgctxt) + 1;
228 size_t msgid_len = strlen(msgid) + 1;
229 const char* translation;
230 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
231 char msg_ctxt_id[msgctxt_len + msgid_len];
234 char* msg_ctxt_id = (msgctxt_len + msgid_len <=
sizeof(buf) ? buf : (
char*)malloc(msgctxt_len + msgid_len));
235 if (msg_ctxt_id != NULL)
238 memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
239 msg_ctxt_id[msgctxt_len - 1] =
'\004';
240 memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
241 translation = dcngettext(domain, msg_ctxt_id, msgid_plural, n, category);
242 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
243 if (msg_ctxt_id != buf)
246 if (!(translation == msg_ctxt_id || translation == msgid_plural))
249 return (n == 1 ? msgid : msgid_plural);