a42820a15d1a28473d4983da1c67d27277b937cb
[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         setlocale(LC_MESSAGES, "");
17         bindtextdomain(PROJECT_NAME, path);
18         textdomain(PROJECT_NAME);
19 #endif
20 }
21
22 inline wchar_t* chartowchar_t(const char *str)
23 {
24         size_t l = strlen(str)+1;
25         wchar_t* nstr = new wchar_t[l];
26         mbstowcs(nstr, str, l);
27         return nstr;
28 }
29
30 inline void changeCtype(const char *l)
31 {
32         char *ret = NULL;
33         ret = setlocale(LC_CTYPE, l);
34         if(ret == NULL)
35                 std::cout<<"locale could not be set"<<std::endl;
36         else
37                 std::cout<<"locale has been set to:"<<ret<<std::endl;
38 }
39 #define GETTEXT_HEADER
40 #endif