00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _LIBGETTEXT_H
00020 #define _LIBGETTEXT_H 1
00021
00022
00023 #if ENABLE_NLS
00024
00025
00026 # include <libintl.h>
00027
00028
00029
00030
00031 # ifdef DEFAULT_TEXT_DOMAIN
00032 # undef gettext
00033 # define gettext(Msgid) \
00034 dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
00035 # undef ngettext
00036 # define ngettext(Msgid1, Msgid2, N) \
00037 dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
00038 # endif
00039
00040 #else
00041
00042
00043
00044
00045
00046
00047
00048 #if defined(__sun)
00049 # include <locale.h>
00050 #endif
00051
00052
00053
00054
00055 #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
00056 # include <cstdlib>
00057 # if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
00058 # include <libintl.h>
00059 # endif
00060 #endif
00061
00062
00063
00064
00065
00066
00067 # define gettext(Msgid) ((const char *) (Msgid))
00068 # define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
00069 # define dcgettext(Domainname, Msgid, Category) \
00070 ((void) (Category), dgettext (Domainname, Msgid))
00071 # define ngettext(Msgid1, Msgid2, N) \
00072 ((N) == 1 \
00073 ? ((void) (Msgid2), (const char *) (Msgid1)) \
00074 : ((void) (Msgid1), (const char *) (Msgid2)))
00075 # define dngettext(Domainname, Msgid1, Msgid2, N) \
00076 ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
00077 # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
00078 ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
00079 # define textdomain(Domainname) ((const char *) (Domainname))
00080 # define bindtextdomain(Domainname, Dirname) \
00081 ((void) (Domainname), (const char *) (Dirname))
00082 # define bind_textdomain_codeset(Domainname, Codeset) \
00083 ((void) (Domainname), (const char *) (Codeset))
00084
00085 #endif
00086
00087
00088
00089
00090
00091
00092
00093
00094 #define gettext_noop(String) String
00095
00096
00097 #define GETTEXT_CONTEXT_GLUE "\004"
00098
00099
00100
00101
00102
00103 #ifdef DEFAULT_TEXT_DOMAIN
00104 # define pgettext(Msgctxt, Msgid) \
00105 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00106 #else
00107 # define pgettext(Msgctxt, Msgid) \
00108 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00109 #endif
00110 #define dpgettext(Domainname, Msgctxt, Msgid) \
00111 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00112 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
00113 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
00114 #ifdef DEFAULT_TEXT_DOMAIN
00115 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
00116 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00117 #else
00118 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
00119 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00120 #endif
00121 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
00122 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00123 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
00124 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
00125
00126 #ifdef __GNUC__
00127 __inline
00128 #else
00129 #ifdef __cplusplus
00130 inline
00131 #endif
00132 #endif
00133 static const char *
00134 pgettext_aux (const char *domain,
00135 const char *msg_ctxt_id, const char *msgid,
00136 int category)
00137 {
00138 const char *translation = dcgettext (domain, msg_ctxt_id, category);
00139 if (translation == msg_ctxt_id)
00140 return msgid;
00141 else
00142 return translation;
00143 }
00144
00145 #ifdef __GNUC__
00146 __inline
00147 #else
00148 #ifdef __cplusplus
00149 inline
00150 #endif
00151 #endif
00152 static const char *
00153 npgettext_aux (const char *domain,
00154 const char *msg_ctxt_id, const char *msgid,
00155 const char *msgid_plural, unsigned long int n,
00156 int category)
00157 {
00158 const char *translation =
00159 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
00160 if (translation == msg_ctxt_id || translation == msgid_plural)
00161 return (n == 1 ? msgid : msgid_plural);
00162 else
00163 return translation;
00164 }
00165
00166
00167
00168
00169
00170 #include <string.h>
00171
00172 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
00173 (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
00174 )
00175
00176 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00177 #include <stdlib.h>
00178 #endif
00179
00180 #define pgettext_expr(Msgctxt, Msgid) \
00181 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
00182 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
00183 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
00184
00185 #ifdef __GNUC__
00186 __inline
00187 #else
00188 #ifdef __cplusplus
00189 inline
00190 #endif
00191 #endif
00192 static const char *
00193 dcpgettext_expr (const char *domain,
00194 const char *msgctxt, const char *msgid,
00195 int category)
00196 {
00197 size_t msgctxt_len = strlen (msgctxt) + 1;
00198 size_t msgid_len = strlen (msgid) + 1;
00199 const char *translation;
00200 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00201 char msg_ctxt_id[msgctxt_len + msgid_len];
00202 #else
00203 char buf[1024];
00204 char *msg_ctxt_id =
00205 (msgctxt_len + msgid_len <= sizeof (buf)
00206 ? buf
00207 : (char *) malloc (msgctxt_len + msgid_len));
00208 if (msg_ctxt_id != NULL)
00209 #endif
00210 {
00211 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
00212 msg_ctxt_id[msgctxt_len - 1] = '\004';
00213 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
00214 translation = dcgettext (domain, msg_ctxt_id, category);
00215 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00216 if (msg_ctxt_id != buf)
00217 free (msg_ctxt_id);
00218 #endif
00219 if (translation != msg_ctxt_id)
00220 return translation;
00221 }
00222 return msgid;
00223 }
00224
00225 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
00226 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
00227 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
00228 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
00229
00230 #ifdef __GNUC__
00231 __inline
00232 #else
00233 #ifdef __cplusplus
00234 inline
00235 #endif
00236 #endif
00237 static const char *
00238 dcnpgettext_expr (const char *domain,
00239 const char *msgctxt, const char *msgid,
00240 const char *msgid_plural, unsigned long int n,
00241 int category)
00242 {
00243 size_t msgctxt_len = strlen (msgctxt) + 1;
00244 size_t msgid_len = strlen (msgid) + 1;
00245 const char *translation;
00246 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00247 char msg_ctxt_id[msgctxt_len + msgid_len];
00248 #else
00249 char buf[1024];
00250 char *msg_ctxt_id =
00251 (msgctxt_len + msgid_len <= sizeof (buf)
00252 ? buf
00253 : (char *) malloc (msgctxt_len + msgid_len));
00254 if (msg_ctxt_id != NULL)
00255 #endif
00256 {
00257 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
00258 msg_ctxt_id[msgctxt_len - 1] = '\004';
00259 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
00260 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
00261 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00262 if (msg_ctxt_id != buf)
00263 free (msg_ctxt_id);
00264 #endif
00265 if (!(translation == msg_ctxt_id || translation == msgid_plural))
00266 return translation;
00267 }
00268 return (n == 1 ? msgid : msgid_plural);
00269 }
00270
00271 #endif