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