this fixes problem with msvc++ and should work on other systems and so on anyway.
[oweals/minetest.git] / src / gettext.h
1 #ifndef GETTEXT_HEADER
2 #include "config.h" // for USE_GETTEXT
3
4 #if USE_GETTEXT
5 #include <libintl.h>
6 #else
7 #define gettext(String) String
8 #endif
9
10 #define _(String) gettext(String)
11 #define gettext_noop(String) String
12 #define N_(String) gettext_noop (String)
13
14 inline void init_gettext(const char *path) {
15 #if USE_GETTEXT
16         bindtextdomain(PROJECT_NAME, path);
17         textdomain(PROJECT_NAME);
18 #endif
19 }
20
21 inline wchar_t* chartowchar_t(const char *str)
22 {
23         size_t l = strlen(str)+1;
24         wchar_t* nstr = new wchar_t[l];
25         mbstowcs(nstr, str, l);
26         return nstr;
27 }
28
29 inline void changeCtype(const char *l)
30 {
31         char *ret = NULL;
32         ret = setlocale(LC_CTYPE, l);
33         if(ret == NULL)
34                 std::cout<<"locale could not be set"<<std::endl;
35         else
36                 std::cout<<"locale has been set to:"<<ret<<std::endl;
37 }
38 #define GETTEXT_HEADER
39 #endif