3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef GETTEXT_HEADER
21 #define GETTEXT_HEADER
23 #include "config.h" // for USE_GETTEXT
29 #define gettext(String) String
32 #define _(String) gettext(String)
33 #define gettext_noop(String) String
34 #define N_(String) gettext_noop (String)
37 #define WIN32_LEAN_AND_MEAN
39 #define _WIN32_WINNT 0x0501
43 #endif // #if defined(_WIN32)
46 void init_gettext(const char *path,std::string configured_language,int argc, char** argv);
48 void init_gettext(const char *path,std::string configured_language);
51 extern std::wstring narrow_to_wide(const std::string& mbs);
52 #include "util/numeric.h"
55 /******************************************************************************/
56 inline wchar_t* chartowchar_t(const char *str)
60 int nResult = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, 0, 0 );
63 errorstream<<"gettext: MultiByteToWideChar returned null"<<std::endl;
67 nstr = new wchar_t[nResult];
68 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult );
71 size_t l = strlen(str)+1;
72 nstr = new wchar_t[l];
74 std::wstring intermediate = narrow_to_wide(str);
76 memcpy(nstr,intermediate.c_str(),l*sizeof(wchar_t));
82 /******************************************************************************/
83 inline wchar_t* wgettext(const char *str)
85 return chartowchar_t(gettext(str));
88 /******************************************************************************/
89 inline std::wstring wstrgettext(std::string text) {
90 wchar_t* wlabel = wgettext(text.c_str());
91 std::wstring out = (std::wstring)wlabel;