2 #include "config.h" // for USE_GETTEXT
8 #define gettext(String) String
11 #define _(String) gettext(String)
12 #define gettext_noop(String) String
13 #define N_(String) gettext_noop (String)
16 #define WIN32_LEAN_AND_MEAN
20 inline void init_gettext(const char *path) {
22 // don't do this if MSVC compiler is used, it gives an assertion fail
24 setlocale(LC_MESSAGES, "");
26 bindtextdomain(PROJECT_NAME, path);
27 textdomain(PROJECT_NAME);
29 // As linux is successfully switched to UTF-8 completely at about year 2005
30 // Windows still uses obsolete codepage based locales because you
31 // cannot recompile closed-source applications
33 // Set character encoding for Win32
34 char *tdomain = textdomain( (char *) NULL );
37 fprintf( stderr, "warning: domainname parameter is the null pointer, default domain is not set\n" );
38 tdomain = (char *) "messages";
40 /*char *codeset = */bind_textdomain_codeset( tdomain, "UTF-8" );
41 //fprintf( stdout, "%s: debug: domainname = %s; codeset = %s\n", argv[0], tdomain, codeset );
42 #endif // defined(_WIN32)
46 inline wchar_t* chartowchar_t(const char *str)
50 int nResult = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, 0, 0 );
53 fprintf( stderr, "error: MultiByteToWideChar returned null\n" );
57 nstr = new wchar_t[nResult];
58 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult );
61 size_t l = strlen(str)+1;
62 nstr = new wchar_t[l];
63 mbstowcs(nstr, str, l);
69 inline wchar_t* wgettext(const char *str)
71 return chartowchar_t(gettext(str));
74 inline void changeCtype(const char *l)
77 ret = setlocale(LC_CTYPE, l);
79 infostream<<"locale could not be set"<<std::endl;
81 infostream<<"locale has been set to:"<<ret<<std::endl;*/
83 #define GETTEXT_HEADER