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 /******************************************************************************/
52 inline wchar_t* chartowchar_t(const char *str)
56 int nResult = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, 0, 0 );
59 errorstream<<"gettext: MultiByteToWideChar returned null"<<std::endl;
63 nstr = new wchar_t[nResult];
64 MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult );
67 size_t l = strlen(str)+1;
68 nstr = new wchar_t[l];
69 mbstowcs(nstr, str, l);
75 /******************************************************************************/
76 inline wchar_t* wgettext(const char *str)
78 return chartowchar_t(gettext(str));
81 /******************************************************************************/
82 inline std::wstring wstrgettext(std::string text) {
83 wchar_t* wlabel = wgettext(text.c_str());
84 std::wstring out = (std::wstring)wlabel;