From e7a3cc012bbdacf7121ab323a68dbeb122331d2f Mon Sep 17 00:00:00 2001 From: driAn Date: Wed, 12 Aug 2009 19:12:17 +0000 Subject: [PATCH] added libintl for localization git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4628 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/include/libintl.h | 393 +++++++++++++++++++++++++++++++++++++++ source/lib/libintl.lib | Bin 0 -> 15922 bytes source/src/pch.h | 1 + source/src/tools.h | 2 + source/vcpp/cube.vcproj | 2 +- 5 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 source/include/libintl.h create mode 100644 source/lib/libintl.lib diff --git a/source/include/libintl.h b/source/include/libintl.h new file mode 100644 index 00000000..b63f8106 --- /dev/null +++ b/source/include/libintl.h @@ -0,0 +1,393 @@ +/* Message catalogs for internationalization. + Copyright (C) 1995-1997, 2000-2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifndef _LIBINTL_H +#define _LIBINTL_H 1 + +#ifdef LIBINTL_STATIC +#define LIBINTL_DLL_EXPORTED +#else /* LIBINTL_STATIC */ +#ifdef BUILDING_LIBINTL +#define LIBINTL_DLL_EXPORTED __declspec(dllexport) +#else +#define LIBINTL_DLL_EXPORTED __declspec(dllimport) +#endif +#endif /* LIBINTL_STATIC */ + +#include + +/* The LC_MESSAGES locale category is the category used by the functions + gettext() and dgettext(). It is specified in POSIX, but not in ANSI C. + On systems that don't define it, use an arbitrary value instead. + On Solaris, defines __LOCALE_H (or _LOCALE_H in Solaris 2.5) + then includes (i.e. this file!) and then only defines + LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES + in this case. */ +#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun)) +# define LC_MESSAGES 1729 +#endif + +/* We define an additional symbol to signal that we use the GNU + implementation of gettext. */ +#define __USE_GNU_GETTEXT 1 + +/* Provide information about the supported file formats. Returns the + maximum minor revision number supported for a given major revision. */ +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ + ((major) == 0 || (major) == 1 ? 1 : -1) + +/* Resolve a platform specific conflict on DJGPP. GNU gettext takes + precedence over _conio_gettext. */ +#ifdef __DJGPP__ +# undef gettext +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* We redirect the functions to those prefixed with "libintl_". This is + necessary, because some systems define gettext/textdomain/... in the C + library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer). + If we used the unprefixed names, there would be cases where the + definition in the C library would override the one in the libintl.so + shared library. Recall that on ELF systems, the symbols are looked + up in the following order: + 1. in the executable, + 2. in the shared libraries specified on the link command line, in order, + 3. in the dependencies of the shared libraries specified on the link + command line, + 4. in the dlopen()ed shared libraries, in the order in which they were + dlopen()ed. + The definition in the C library would override the one in libintl.so if + either + * -lc is given on the link command line and -lintl isn't, or + * -lc is given on the link command line before -lintl, or + * libintl.so is a dependency of a dlopen()ed shared library but not + linked to the executable at link time. + Since Solaris gettext() behaves differently than GNU gettext(), this + would be unacceptable. + + The redirection happens by default through macros in C, so that &gettext + is independent of the compilation unit, but through inline functions in + C++, in order not to interfere with the name mangling of class fields or + class methods called 'gettext'. */ + +/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS. + If he doesn't, we choose the method. A third possible method is + _INTL_REDIRECT_ASM, supported only by GCC. */ +#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS) +# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus) +# define _INTL_REDIRECT_ASM +# else +# ifdef __cplusplus +# define _INTL_REDIRECT_INLINE +# else +# define _INTL_REDIRECT_MACROS +# endif +# endif +#endif +/* Auxiliary macros. */ +#ifdef _INTL_REDIRECT_ASM +# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname)) +# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring +# define _INTL_STRINGIFY(prefix) #prefix +#else +# define _INTL_ASM(cname) +#endif + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_gettext (const char *__msgid); +static inline char *gettext (const char *__msgid) +{ + return libintl_gettext (__msgid); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define gettext libintl_gettext +#endif +extern LIBINTL_DLL_EXPORTED char *gettext (const char *__msgid) + _INTL_ASM (libintl_gettext); +#endif + +/* Look up MSGID in the DOMAINNAME message catalog for the current + LC_MESSAGES locale. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_dgettext (const char *__domainname, const char *__msgid); +static inline char *dgettext (const char *__domainname, const char *__msgid) +{ + return libintl_dgettext (__domainname, __msgid); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dgettext libintl_dgettext +#endif +extern LIBINTL_DLL_EXPORTED char *dgettext (const char *__domainname, const char *__msgid) + _INTL_ASM (libintl_dgettext); +#endif + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_dcgettext (const char *__domainname, const char *__msgid, + int __category); +static inline char *dcgettext (const char *__domainname, const char *__msgid, + int __category) +{ + return libintl_dcgettext (__domainname, __msgid, __category); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dcgettext libintl_dcgettext +#endif +extern LIBINTL_DLL_EXPORTED char *dcgettext (const char *__domainname, const char *__msgid, + int __category) + _INTL_ASM (libintl_dcgettext); +#endif + + +/* Similar to `gettext' but select the plural form corresponding to the + number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n); +static inline char *ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n) +{ + return libintl_ngettext (__msgid1, __msgid2, __n); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define ngettext libintl_ngettext +#endif +extern LIBINTL_DLL_EXPORTED char *ngettext (const char *__msgid1, const char *__msgid2, + unsigned long int __n) + _INTL_ASM (libintl_ngettext); +#endif + +/* Similar to `dgettext' but select the plural form corresponding to the + number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_dngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n); +static inline char *dngettext (const char *__domainname, const char *__msgid1, + const char *__msgid2, unsigned long int __n) +{ + return libintl_dngettext (__domainname, __msgid1, __msgid2, __n); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dngettext libintl_dngettext +#endif +extern LIBINTL_DLL_EXPORTED char *dngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n) + _INTL_ASM (libintl_dngettext); +#endif + +/* Similar to `dcgettext' but select the plural form corresponding to the + number N. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category); +static inline char *dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category) +{ + return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define dcngettext libintl_dcngettext +#endif +extern LIBINTL_DLL_EXPORTED char *dcngettext (const char *__domainname, + const char *__msgid1, const char *__msgid2, + unsigned long int __n, int __category) + _INTL_ASM (libintl_dcngettext); +#endif + + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_textdomain (const char *__domainname); +static inline char *textdomain (const char *__domainname) +{ + return libintl_textdomain (__domainname); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define textdomain libintl_textdomain +#endif +extern LIBINTL_DLL_EXPORTED char *textdomain (const char *__domainname) + _INTL_ASM (libintl_textdomain); +#endif + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_bindtextdomain (const char *__domainname, + const char *__dirname); +static inline char *bindtextdomain (const char *__domainname, + const char *__dirname) +{ + return libintl_bindtextdomain (__domainname, __dirname); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define bindtextdomain libintl_bindtextdomain +#endif +extern LIBINTL_DLL_EXPORTED char *bindtextdomain (const char *__domainname, const char *__dirname) + _INTL_ASM (libintl_bindtextdomain); +#endif + +/* Specify the character encoding in which the messages from the + DOMAINNAME message catalog will be returned. */ +#ifdef _INTL_REDIRECT_INLINE +extern LIBINTL_DLL_EXPORTED char *libintl_bind_textdomain_codeset (const char *__domainname, + const char *__codeset); +static inline char *bind_textdomain_codeset (const char *__domainname, + const char *__codeset) +{ + return libintl_bind_textdomain_codeset (__domainname, __codeset); +} +#else +#ifdef _INTL_REDIRECT_MACROS +# define bind_textdomain_codeset libintl_bind_textdomain_codeset +#endif +extern LIBINTL_DLL_EXPORTED char *bind_textdomain_codeset (const char *__domainname, + const char *__codeset) + _INTL_ASM (libintl_bind_textdomain_codeset); +#endif + + +/* Support for format strings with positions in *printf(), following the + POSIX/XSI specification. + Note: These replacements for the *printf() functions are visible only + in source files that #include or #include "gettext.h". + Packages that use *printf() in source files that don't refer to _() + or gettext() but for which the format string could be the return value + of _() or gettext() need to add this #include. Oh well. */ + +#if !0 + +#include +#include + +/* Get va_list. */ +#if __STDC__ || defined __cplusplus || defined _MSC_VER +# include +#else +# include +#endif + +#undef fprintf +#define fprintf libintl_fprintf +extern LIBINTL_DLL_EXPORTED int fprintf (FILE *, const char *, ...); +#undef vfprintf +#define vfprintf libintl_vfprintf +extern LIBINTL_DLL_EXPORTED int vfprintf (FILE *, const char *, va_list); + +#undef printf +#define printf libintl_printf +extern LIBINTL_DLL_EXPORTED int printf (const char *, ...); +#undef vprintf +#define vprintf libintl_vprintf +extern LIBINTL_DLL_EXPORTED int vprintf (const char *, va_list); + +#undef sprintf +#define sprintf libintl_sprintf +extern LIBINTL_DLL_EXPORTED int sprintf (char *, const char *, ...); +#undef vsprintf +#define vsprintf libintl_vsprintf +extern LIBINTL_DLL_EXPORTED int vsprintf (char *, const char *, va_list); + +#if 0 + +#undef snprintf +#define snprintf libintl_snprintf +extern LIBINTL_DLL_EXPORTED int snprintf (char *, size_t, const char *, ...); +#undef vsnprintf +#define vsnprintf libintl_vsnprintf +extern LIBINTL_DLL_EXPORTED int vsnprintf (char *, size_t, const char *, va_list); + +#endif + +#if 0 + +#undef asprintf +#define asprintf libintl_asprintf +extern LIBINTL_DLL_EXPORTED int asprintf (char **, const char *, ...); +#undef vasprintf +#define vasprintf libintl_vasprintf +extern LIBINTL_DLL_EXPORTED int vasprintf (char **, const char *, va_list); + +#endif + +#if 1 + +#undef fwprintf +#define fwprintf libintl_fwprintf +extern LIBINTL_DLL_EXPORTED int fwprintf (FILE *, const wchar_t *, ...); +#undef vfwprintf +#define vfwprintf libintl_vfwprintf +extern LIBINTL_DLL_EXPORTED int vfwprintf (FILE *, const wchar_t *, va_list); + +#undef wprintf +#define wprintf libintl_wprintf +extern LIBINTL_DLL_EXPORTED int wprintf (const wchar_t *, ...); +#undef vwprintf +#define vwprintf libintl_vwprintf +extern LIBINTL_DLL_EXPORTED int vwprintf (const wchar_t *, va_list); + +#undef swprintf +#define swprintf libintl_swprintf +extern LIBINTL_DLL_EXPORTED int swprintf (wchar_t *, size_t, const wchar_t *, ...); +#undef vswprintf +#define vswprintf libintl_vswprintf +extern LIBINTL_DLL_EXPORTED int vswprintf (wchar_t *, size_t, const wchar_t *, va_list); + +#endif + +#endif + + +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +#define libintl_set_relocation_prefix libintl_set_relocation_prefix +extern LIBINTL_DLL_EXPORTED void + libintl_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + + +#ifdef __cplusplus +} +#endif + +#endif /* libintl.h */ diff --git a/source/lib/libintl.lib b/source/lib/libintl.lib new file mode 100644 index 0000000000000000000000000000000000000000..4b7ffd2b2e36916775b93846e260b3cdf3bbb7bc GIT binary patch literal 15922 zcmd5@OK)677CugZ1SbTO@SKFC^R^Sm@uRyPCk{A{!z2&_3TDItantE;+s#~eTitC> zG$S!ASfTs?RtT|~4bre;k=Y>4Cek1cVvvSqX2X)%AcV5Xe06U1_z0oE{SZUQTL8o#0#2Nj_#7c{5_SYwK`3x9#PEAW0lr5FoSKvP3L!8uDDeqG z;PiHhHG~2`h8UeE3V?DL1;$v>mRfAfv&^WNO0w=Q14^5*;-*FC>+v(fDO6Xbc<-oAP@szHBNDxt#s<+rcB z=FMH0zd+uc@Bg;m{awA?X|$S1p|QN;#S6Wr@6~UuRGKxf;x{TCC`TnhbSd{+wYt}= zEZ4OrmuSs}22!lGmMaaxk0fn@t>;&oi>sAInPi~JM7Hj7XOSfsz8Q^ny)Ie3YOA>> zHKS4;qtR@1qcLKnI)=)bx6-aJ)Z6uDwchb+^@Yl+-wpZJ(J(2sDs~z9mVoJ1D?TrD zzr_V{dQOInKKl?GZ>7~~+>&OnSW3*|EPAWWZoAU#_?2$GrlLfoI>vJ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vt7D0Ic2Ak@Kn5g+RJky`!c>f({N6v;*W@L@lHW@un`q*1GM zD@U+O44gD-c+*qk?}KQ@HXNxe&pXE2rD|i+-^t8L-#Z6xP*^rj{j6IGGzS> zyENe=^!}w@WVp%Yo25*#+m&*-oZCAW&xBJZo%Cv-@X$CG#~u=@&pxf@l}7v} zOAVG(1v*^VybEeEdb-USD7S5Ce8RCPJ~K=1kxyMAaqJUSCR$JAsNJIDFPTbHxez!P%0YmhUF$H^4aXRbp9vM?cj{%HTft7GQ=4MKdd?_{gl(I0ot6-7xmrSiErOoaZoJm^; zoG5pjEl$O^SuuUvqgdJE&?3v-a*D-xw&%el=CJItjzz>@vXo^pp;x>Bj%Pw1z4Ya2 z=O3+#34P%?usjuP0zG;0;FEwN4h+>AX%h>EJT7}GCvb3C1 zLQfE*La-Q=38IhdZA;FPzgE*2#k`wYxJkV|t=)>1jA4xJCb|7(S{)WFzIX$9`DUua zlsTcOM{S?l(BuTU$DXv(JY=z{4NQwJe`%&zCsr5Qy4cF&+*!)9oG=FA+DP!<04|$* z_mA^!pl>9M>&L+^{7!^j@6q?ho91bciJ6*AUX3FN?Hh>}J%7nk=B0!(7qu%aciF@9 z2hOsAl1`bM;yRJxjPIhkTX8vIo;V7wAzs2b_)0jewhZPkS;{z#|AfP@FM8VdI5}l* zuTf4YZ(P~JO(E98V87;<*F!Dh{3V~lJnS+%*G_w5PMf6*f1=y9JVWY@EzK{B8Ixwy zr*XaUl@sQ+xM+tPXN)iYtj{9nFIif1nysQoX@~ literal 0 HcmV?d00001 diff --git a/source/src/pch.h b/source/src/pch.h index 9bf2fbf2..7107350e 100644 --- a/source/src/pch.h +++ b/source/src/pch.h @@ -27,6 +27,7 @@ #endif #include +#include #include #ifdef WIN32 diff --git a/source/src/tools.h b/source/src/tools.h index a9791489..41fda40d 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -638,6 +638,8 @@ inline char *newstring(const char *s) { return newstring(s, strlen(s)) inline char *newstringbuf() { return newstring(_MAXDEFSTR-1); } inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); } +#define _(STRING) gettext(STRING) + extern const char *timestring(bool local = false, const char *fmt = NULL); extern const char *asctime(); extern const char *numtime(); diff --git a/source/vcpp/cube.vcproj b/source/vcpp/cube.vcproj index 18ade33a..1d18c4ff 100644 --- a/source/vcpp/cube.vcproj +++ b/source/vcpp/cube.vcproj @@ -189,7 +189,7 @@ />