1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/*
Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WOLF_GETTEXT_H
#define WOLF_GETTEXT_H
/**
* @addtogroup wolf_port Porting
* @{
*/
/**
* @file gettext.h
* @brief localization header, nivelating some problems in gettext/libintl
* @author Andreas Baumann <abaumann@yahoo.com>
*/
/* some distributors like to disable NLS */
#if ENABLE_NLS
/* Some older versions of libintl.h make tests for the value __APPLE_CC though
* this macro can be undefined! Nice, defining it here as 0.
* (Noticed on OpenBSD 4.3)
*/
#if !defined( __APPLE_CC )
#define __APPLE_CC__ 0
#endif
/* define a proper prototype with format_arg so that gcc doesn't croak. This
* is a problem on systems which have an onlder libintl.h where the declarations
* are missing. So we define a first prototype here and hope the compiler survives
* the redefiniton in libintl.h but for a format_arg (urgh!). Experienced only
* on NetBSD 4.1
*/
#if defined __GNUC__
#if defined GETTEXT_NEEDS_FORMAT_ARG
char *gettext( const char *__msgid ) __attribute__ ( ( format_arg ( 1 ) ) );
char *libintl_gettext( const char *__msgid ) __attribute__ ( ( format_arg ( 1 ) ) );
char *dgettext( const char *__domainname, const char *__msgid ) __attribute__ ( ( format_arg ( 2 ) ) );
char *libintl_dgettext( const char *__domainname, const char *__msgid ) __attribute__ ( ( format_arg ( 2 ) ) );
#endif
#endif
#include <libintl.h> /* for gettext, bindtextdomain */
#include <locale.h> /* for setlocale */
/** It's much easier to define a DEFAULT_TEXT_DOMAIN and map gettext to a
* dgettext, so that we don't have to call 'textdomain' anywhere in the
* library. Define this before including gettext.h
*/
#if defined DEFAULT_TEXT_DOMAIN
#undef gettext
#define gettext( msgid ) dgettext( DEFAULT_TEXT_DOMAIN, msgid )
#endif /* defined DEFAULT_TEXT_DOMAIN */
#else /* ENABLE_NLS */
#define gettext( msgid ) ( (const char *)( msgid ) )
#define LC_ALL 1
#define setlocale( category, loc ) ( NULL )
#define bindtextdomain( domain, directory ) ( NULL )
#define textdomain( domain )( NULL )
#endif /* ENABLE_NLS */
/* a noop marker which let's xgettext extract the message but doesn't
* call the gettext() function if NLS is enabled.
*/
#define gettext_noop( s ) s
/* shorthand macro for lazy people */
#define _( s ) gettext( s )
void wolf_port_initialize_i18n( const char *argv0, const char *app );
/** @} */ /* @addtogroup wolf_port */
#endif /* ifndef WOLF_GETTEXT_H */
|