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) ((const char *) (Msgid))
00069 # define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
00070 # define ngettext(Msgid1, Msgid2, N) \
00071 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
00072 # define dngettext(Domainname, Msgid1, Msgid2, N) \
00073 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
00074 # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
00075 ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
00076 # define textdomain(Domainname) ((const char *) (Domainname))
00077 # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
00078 # define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
00079
00080 #endif
00081
00082
00083
00084
00085
00086
00087
00088
00089 #define gettext_noop(String) String
00090
00091
00092 #define GETTEXT_CONTEXT_GLUE "\004"
00093
00094
00095
00096
00097
00098 #ifdef DEFAULT_TEXT_DOMAIN
00099 # define pgettext(Msgctxt, Msgid) \
00100 pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00101 #else
00102 # define pgettext(Msgctxt, Msgid) \
00103 pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00104 #endif
00105 #define dpgettext(Domainname, Msgctxt, Msgid) \
00106 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
00107 #define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
00108 pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
00109 #ifdef DEFAULT_TEXT_DOMAIN
00110 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
00111 npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00112 #else
00113 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
00114 npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00115 #endif
00116 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
00117 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
00118 #define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
00119 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
00120
00121 #ifdef __GNUC__
00122 __inline
00123 #else
00124 #ifdef __cplusplus
00125 inline
00126 #endif
00127 #endif
00128 static const char *
00129 pgettext_aux (const char *domain,
00130 const char *msg_ctxt_id, const char *msgid,
00131 int category)
00132 {
00133 const char *translation = dcgettext (domain, msg_ctxt_id, category);
00134 if (translation == msg_ctxt_id)
00135 return msgid;
00136 else
00137 return translation;
00138 }
00139
00140 #ifdef __GNUC__
00141 __inline
00142 #else
00143 #ifdef __cplusplus
00144 inline
00145 #endif
00146 #endif
00147 static const char *
00148 npgettext_aux (const char *domain,
00149 const char *msg_ctxt_id, const char *msgid,
00150 const char *msgid_plural, unsigned long int n,
00151 int category)
00152 {
00153 const char *translation =
00154 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
00155 if (translation == msg_ctxt_id || translation == msgid_plural)
00156 return (n == 1 ? msgid : msgid_plural);
00157 else
00158 return translation;
00159 }
00160
00161
00162
00163
00164
00165 #include <string.h>
00166
00167 #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
00168 (__STRICT_ANSI__ - 0 == 0) && (__GNUC__ >= 3 || __GNUG__ >= 2 )
00169
00170 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00171 #include <stdlib.h>
00172 #endif
00173
00174 #define pgettext_expr(Msgctxt, Msgid) \
00175 dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
00176 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
00177 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
00178
00179 #ifdef __GNUC__
00180 __inline
00181 #else
00182 #ifdef __cplusplus
00183 inline
00184 #endif
00185 #endif
00186 static const char *
00187 dcpgettext_expr (const char *domain,
00188 const char *msgctxt, const char *msgid,
00189 int category)
00190 {
00191 size_t msgctxt_len = strlen (msgctxt) + 1;
00192 size_t msgid_len = strlen (msgid) + 1;
00193 const char *translation;
00194 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00195 char msg_ctxt_id[msgctxt_len + msgid_len];
00196 #else
00197 char buf[1024];
00198 char *msg_ctxt_id =
00199 (msgctxt_len + msgid_len <= sizeof (buf)
00200 ? buf
00201 : (char *) malloc (msgctxt_len + msgid_len));
00202 if (msg_ctxt_id != NULL)
00203 #endif
00204 {
00205 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
00206 msg_ctxt_id[msgctxt_len - 1] = '\004';
00207 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
00208 translation = dcgettext (domain, msg_ctxt_id, category);
00209 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00210 if (msg_ctxt_id != buf)
00211 free (msg_ctxt_id);
00212 #endif
00213 if (translation != msg_ctxt_id)
00214 return translation;
00215 }
00216 return msgid;
00217 }
00218
00219 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
00220 dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
00221 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
00222 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
00223
00224 #ifdef __GNUC__
00225 __inline
00226 #else
00227 #ifdef __cplusplus
00228 inline
00229 #endif
00230 #endif
00231 static const char *
00232 dcnpgettext_expr (const char *domain,
00233 const char *msgctxt, const char *msgid,
00234 const char *msgid_plural, unsigned long int n,
00235 int category)
00236 {
00237 size_t msgctxt_len = strlen (msgctxt) + 1;
00238 size_t msgid_len = strlen (msgid) + 1;
00239 const char *translation;
00240 #if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00241 char msg_ctxt_id[msgctxt_len + msgid_len];
00242 #else
00243 char buf[1024];
00244 char *msg_ctxt_id =
00245 (msgctxt_len + msgid_len <= sizeof (buf)
00246 ? buf
00247 : (char *) malloc (msgctxt_len + msgid_len));
00248 if (msg_ctxt_id != NULL)
00249 #endif
00250 {
00251 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
00252 msg_ctxt_id[msgctxt_len - 1] = '\004';
00253 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
00254 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
00255 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
00256 if (msg_ctxt_id != buf)
00257 free (msg_ctxt_id);
00258 #endif
00259 if (!(translation == msg_ctxt_id || translation == msgid_plural))
00260 return translation;
00261 }
00262 return (n == 1 ? msgid : msgid_plural);
00263 }
00264
00265 #endif