cwidget 0.5.18
i18n.h
1// globals.h -*-c++-*-
2//
3// Copyright (C) 2007, 2011 Daniel Burrows
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License as
7// published by the Free Software Foundation; either version 2 of
8// the License, or (at your option) any later version.
9//
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 GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; see the file COPYING. If not, write to
17// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18// Boston, MA 02111-1307, USA.
19
20#ifndef I18N_H
21#define I18N_H
22
23#include <config.h>
24
25// i18n definitions
26
27#define CWIDGET_DOMAIN "libcwidget4"
28
29
30#ifdef HAVE_LOCALE_H
31# include <locale.h>
32#endif
33#ifndef HAVE_SETLOCALE
34inline void setlocale(int, const char *)
35{
36}
37#endif
38
39#if ENABLE_NLS
40# include <libintl.h>
41# include <string.h>
42# define _(Text) dgettext (CWIDGET_DOMAIN, Text)
43# define W_(Text) transcode ( _(Text) )
44# define N_(Text) Text
45
49#ifdef __GNUG__
50__attribute__ ((format_arg(1)))
51#endif
52inline const char *P_(const char *Text)
53{
54 const char * const translation = dgettext(CWIDGET_DOMAIN, Text);
55 const char * const stripto = strchr(translation, '|');
56
57 if(stripto == NULL)
58 return translation;
59 else
60 return stripto+1;
61}
62
63#else
64# undef bindtextdomain
65# define bindtextdomain(Domain, Directory) /* empty */
66# undef textdomain
67# define textdomain(Domain) /* empty */
68# define _(Text) Text
69# define N_(Text) Text
70inline const char *P_(const char *Text)
71{
72 const char * const stripto = strchr(Text, '|');
73 return stripto+1;
74}
75# define gettext(Text) Text
76# define dgettext(Domain, Text) Text
77#endif
78
79
80#endif // GLOBALS_H