Bumped copyright dates for 2013
[barry.git] / desktop / src / wxi18n.h
blobc26962ceb4d359aea6ec7dd737c30636d16dd639
1 ///
2 /// \file wxi18n.h
3 /// Internationalization header for wxWidgets code
4 ///
5 /// Note: the i18n headers are intentionally split between non-wxWidgets code
6 /// and wxWidgets code, via i18n.h and wxi18n.h. This is so that,
7 /// wxWidgets's version of _() is guaranteed to be removed in favour
8 /// of our own _W(), and so prevent confusion. Also, the osyncwrap
9 /// library code does not strictly depend on wxWidgets, and so should
10 /// not use any of its headers nor defines nor its wxString. Keeping
11 /// libosyncwrap separate should make it easier to turn it into a
12 /// standalone library someday.
13 ///
16 Copyright (C) 2012-2013, Net Direct Inc. (http://www.netdirect.ca/)
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 See the GNU General Public License in the COPYING file at the
28 root directory of this project for more details.
31 #ifndef __BARRY_DESKTOP_WXI18N_H__
32 #define __BARRY_DESKTOP_WXI18N_H__
34 // Make sure that i18n.h is not included in this module
35 #ifdef __BARRY_DESKTOP_I18N_H__
36 #error Cannot include both i18n.h and wxi18n.h in same module.
37 #endif
39 #include <config.h>
40 #include <locale.h>
42 // For the osyncwrap library, it uses gettext, not wxWidgets, so we need
43 // to make sure we initialize gettext if it is available.
45 // The bindtextdomain define was taken from gettext.h.
46 #if ENABLE_NLS
47 #include <libintl.h>
48 #else
49 # define bindtextdomain(Domainname, Dirname) \
50 ((void) (Domainname), (const char *) (Dirname))
51 #endif
53 // Make sure wxWidgets' version of _() does not affect us
54 #include <wx/wx.h>
55 #undef _
57 // Define our own _W() macro, used wherever we'd normally use _T() style
58 // strings, which creates a wxString on the fly.
59 // For wxString(_W("blah blah"))
60 #define _W(x) wxString(wxGetTranslation(_T(x)))
62 // For plain old const char* strings...
63 // Note! this returns a temporary const string!
64 // Do not rely on its existence beyond the statement it lives in.
65 #define _C(x) wxString(wxGetTranslation(_T(x))).utf8_str().data()
67 // Convenience macro to initialize i18n, using wxWidgets
68 #define INIT_I18N(package) { \
69 /* Do gettext first, if possible, for libosyncwrap */ \
70 setlocale(LC_ALL, ""); \
71 bindtextdomain("barryosyncwrap", LOCALEDIR); \
72 /* Init wxWidgets */ \
73 static wxLocale locale; \
74 locale.Init(); \
75 locale.AddCatalogLookupPathPrefix(_T(LOCALEDIR)); \
76 locale.AddCatalog(_T(package)); \
79 #endif