aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/I18n.hh
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-06-07 11:46:05 (GMT)
committerrathnor <rathnor>2004-06-07 11:46:05 (GMT)
commitfff4456dee29e675d7f2ed3490db39bcb7e10e53 (patch)
tree2d2dbf386551773cbdc8231b2a93b493187bd733 /src/FbTk/I18n.hh
parent073065ac56b388db1169108d44f37d32f1d19c67 (diff)
downloadfluxbox_paul-fff4456dee29e675d7f2ed3490db39bcb7e10e53.zip
fluxbox_paul-fff4456dee29e675d7f2ed3490db39bcb7e10e53.tar.bz2
update NLS string handling...
Diffstat (limited to 'src/FbTk/I18n.hh')
-rw-r--r--src/FbTk/I18n.hh112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/FbTk/I18n.hh b/src/FbTk/I18n.hh
new file mode 100644
index 0000000..08f973d
--- /dev/null
+++ b/src/FbTk/I18n.hh
@@ -0,0 +1,112 @@
1// i18n.hh for Fluxbox Window Manager
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
4// i18n.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25// $Id: I18n.hh,v 1.1 2004/06/07 11:46:05 rathnor Exp $
26
27#ifndef I18N_HH
28#define I18N_HH
29
30// TODO: FIXME
31#include "../../nls/fluxbox-nls.hh"
32
33#ifdef HAVE_CONFIG_H
34#include "config.h"
35#endif // HAVE_CONFIG_H
36
37
38#ifdef HAVE_LOCALE_H
39#include <locale.h>
40#endif // HAVE_LOCALE_H
41
42#ifdef HAVE_NL_TYPES_H
43// this is needed for linux libc5 systems
44extern "C" {
45#include <nl_types.h>
46}
47#elif defined(__CYGWIN__)
48#ifdef __cplusplus
49extern "C" {
50#endif // __cplusplus
51typedef int nl_catd;
52char *catgets(nl_catd cat, int set_number, int message_number, char *message);
53nl_catd catopen(char *name, int flag);
54void catclose(nl_catd cat);
55#ifdef __cplusplus
56}
57#endif // __cplusplus
58
59#endif // HAVE_NL_TYPES_H
60
61#include <string>
62
63// Some defines to help out
64#ifdef NLS
65#define _FB_USES_NLS \
66 FbTk::I18n &i18n = *FbTk::I18n::instance()
67
68// ignore the description, it's for helping translators
69#define _FBTEXT(msgset, msgid, default_text, description) \
70 i18n.getMessage(FBNLS::msgset ## Set, FBNLS::msgset ## msgid, default_text)
71
72// This ensure that FbTk nls stuff is in a kind of namespace of its own
73#define _FBTKTEXT( msgset, msgid, default_text, description) \
74 i18n.getMessage(FBNLS::FbTk ## msgset ## Set, FBNLS::FbTk ## msgset ## msgid, default_text)
75
76#else // no NLS
77
78#define _FB_USES_NLS
79#define _FBTEXT(msgset, msgid, default_text, description) \
80 default_text
81
82#define _FBTKTEXT(msgset, msgid, default_text, description) \
83 default_text
84
85#endif // defined NLS
86
87namespace FbTk {
88
89class I18n {
90public:
91 static I18n *instance();
92 inline const char *getLocale() const { return m_locale.c_str(); }
93 inline bool multibyte() const { return m_multibyte; }
94 inline const nl_catd &getCatalogFd() const { return m_catalog_fd; }
95
96 const char *getMessage(int set_number, int message_number,
97 const char *default_messsage = 0) const;
98 void openCatalog(const char *catalog);
99private:
100 I18n();
101 ~I18n();
102 std::string m_locale;
103 bool m_multibyte;
104 nl_catd m_catalog_fd;
105
106};
107
108void NLSInit(const char *);
109
110}; // end namespace FbTk
111
112#endif // I18N_HH