1 | /* Begin of libgettext.h */ |
---|
2 | |
---|
3 | /* Message catalogs for internationalization. |
---|
4 | Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program; if not, write to the Free Software Foundation, |
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
---|
19 | |
---|
20 | #ifndef _GETTEXT_H |
---|
21 | #define _GETTEXT_H 1 |
---|
22 | |
---|
23 | /* We define an additional symbol to signal that we use the GNU |
---|
24 | implementation of gettext. */ |
---|
25 | #define __USE_GNU_GETTEXT 1 |
---|
26 | |
---|
27 | #include <sys/types.h> |
---|
28 | |
---|
29 | #if HAVE_LOCALE_H |
---|
30 | # include <locale.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | #ifdef __cplusplus |
---|
34 | extern "C" { |
---|
35 | #endif |
---|
36 | |
---|
37 | #ifndef PARAMS |
---|
38 | # if __STDC__ || defined __cplusplus |
---|
39 | # define PARAMS(args) args |
---|
40 | # else |
---|
41 | # define PARAMS(args) () |
---|
42 | # endif |
---|
43 | #endif |
---|
44 | |
---|
45 | #ifndef NULL |
---|
46 | # if !defined __cplusplus || defined __GNUC__ |
---|
47 | # define NULL ((void *) 0) |
---|
48 | # else |
---|
49 | # define NULL (0) |
---|
50 | # endif |
---|
51 | #endif |
---|
52 | |
---|
53 | #if !HAVE_LC_MESSAGES |
---|
54 | /* This value determines the behaviour of the gettext() and dgettext() |
---|
55 | function. But some system does not have this defined. Define it |
---|
56 | to a default value. */ |
---|
57 | # define LC_MESSAGES (-1) |
---|
58 | #endif |
---|
59 | |
---|
60 | /* Declarations for gettext-using-catgets interface. Derived from |
---|
61 | Jim Meyering's libintl.h. */ |
---|
62 | struct _msg_ent |
---|
63 | { |
---|
64 | const char *_msg; |
---|
65 | int _msg_number; |
---|
66 | }; |
---|
67 | |
---|
68 | #if HAVE_CATGETS |
---|
69 | /* These two variables are defined in the automatically by po-to-tbl.sed |
---|
70 | generated file `cat-id-tbl.c'. */ |
---|
71 | extern const struct _msg_ent _msg_tbl[]; |
---|
72 | extern int _msg_tbl_length; |
---|
73 | #endif |
---|
74 | |
---|
75 | /* Look up MSGID in the current default message catalog for the current |
---|
76 | LC_MESSAGES locale. If not found, returns MSGID itself (the default |
---|
77 | text). */ |
---|
78 | extern char *gettext PARAMS ((const char *__msgid)); |
---|
79 | /* static char *gettext__ PARAMS ((const char *__msgid)); */ |
---|
80 | |
---|
81 | /* Look up MSGID in the DOMAINNAME message catalog for the current |
---|
82 | LC_MESSAGES locale. */ |
---|
83 | extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid)); |
---|
84 | /* static char *dgettext__ PARAMS ((const char *__domainname, |
---|
85 | const char *__msgid)); */ |
---|
86 | |
---|
87 | /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY |
---|
88 | locale. */ |
---|
89 | extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid, |
---|
90 | int __category)); |
---|
91 | extern char *dcgettext__ PARAMS ((const char *__domainname, |
---|
92 | const char *__msgid, int __category)); |
---|
93 | |
---|
94 | /* Set the current default message catalog to DOMAINNAME. |
---|
95 | If DOMAINNAME is null, return the current default. |
---|
96 | If DOMAINNAME is "", reset to the default of "messages". */ |
---|
97 | extern char *textdomain PARAMS ((const char *__domainname)); |
---|
98 | /* static char *textdomain__ PARAMS ((const char *__domainname)); */ |
---|
99 | |
---|
100 | /* Specify that the DOMAINNAME message catalog will be found |
---|
101 | in DIRNAME rather than in the system locale data base. */ |
---|
102 | extern char *bindtextdomain PARAMS ((const char *__domainname, |
---|
103 | const char *__dirname)); |
---|
104 | /* static char *bindtextdomain__ PARAMS ((const char *__domainname, |
---|
105 | const char *__dirname)); */ |
---|
106 | |
---|
107 | #if ENABLE_NLS |
---|
108 | |
---|
109 | /* Solaris 2.3 has the gettext function but dcgettext is missing. |
---|
110 | So we omit this optimization for Solaris 2.3. BTW, Solaris 2.4 |
---|
111 | has dcgettext. */ |
---|
112 | # if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT) |
---|
113 | |
---|
114 | # define gettext(Msgid) \ |
---|
115 | dgettext (NULL, Msgid) |
---|
116 | |
---|
117 | # define dgettext(Domainname, Msgid) \ |
---|
118 | dcgettext (Domainname, Msgid, LC_MESSAGES) |
---|
119 | |
---|
120 | # if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7 |
---|
121 | /* This global variable is defined in loadmsgcat.c. We need a sign, |
---|
122 | whether a new catalog was loaded, which can be associated with all |
---|
123 | translations. */ |
---|
124 | extern int _nl_msg_cat_cntr; |
---|
125 | |
---|
126 | # define dcgettext(Domainname, Msgid, Category) \ |
---|
127 | (__extension__ \ |
---|
128 | ({ \ |
---|
129 | char *__result; \ |
---|
130 | if (__builtin_constant_p (Msgid)) \ |
---|
131 | { \ |
---|
132 | static char *__translation__; \ |
---|
133 | static int __catalog_counter__; \ |
---|
134 | if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \ |
---|
135 | { \ |
---|
136 | __translation__ = \ |
---|
137 | dcgettext__ (Domainname, Msgid, Category); \ |
---|
138 | __catalog_counter__ = _nl_msg_cat_cntr; \ |
---|
139 | } \ |
---|
140 | __result = __translation__; \ |
---|
141 | } \ |
---|
142 | else \ |
---|
143 | __result = dcgettext__ (Domainname, Msgid, Category); \ |
---|
144 | __result; \ |
---|
145 | })) |
---|
146 | # endif |
---|
147 | # endif |
---|
148 | |
---|
149 | #else |
---|
150 | |
---|
151 | # define gettext(Msgid) (Msgid) |
---|
152 | # define dgettext(Domainname, Msgid) (Msgid) |
---|
153 | # define dcgettext(Domainname, Msgid, Category) (Msgid) |
---|
154 | # define textdomain(Domainname) ((char *) Domainname) |
---|
155 | # define bindtextdomain(Domainname, Dirname) ((char *) Dirname) |
---|
156 | |
---|
157 | #endif |
---|
158 | |
---|
159 | #ifdef __cplusplus |
---|
160 | } |
---|
161 | #endif |
---|
162 | |
---|
163 | #endif /* _GETTEXT_H */ |
---|
164 | |
---|
165 | /* End of libgettext.h */ |
---|