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