]> git.lizzy.rs Git - minetest.git/blob - src/gettext.h
Merge remote-tracking branch 'origin/upstream'
[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         // don't do this if MSVC compiler is used, it gives an assertion fail
17         #ifndef _MSC_VER
18                 setlocale(LC_MESSAGES, "");
19         #endif
20         bindtextdomain(PROJECT_NAME, path);
21         textdomain(PROJECT_NAME);
22 #endif
23 }
24
25 inline wchar_t* chartowchar_t(const char *str)
26 {
27         size_t l = strlen(str)+1;
28         wchar_t* nstr = new wchar_t[l];
29         mbstowcs(nstr, str, l);
30         return nstr;
31 }
32
33 inline void changeCtype(const char *l)
34 {
35         char *ret = NULL;
36         ret = setlocale(LC_CTYPE, l);
37         if(ret == NULL)
38                 std::cout<<"locale could not be set"<<std::endl;
39         else
40                 std::cout<<"locale has been set to:"<<ret<<std::endl;
41 }
42 #define GETTEXT_HEADER
43 #endif