1 /* libgnuintl.h - Message catalogs for internationalization. */
3 /* Copyright (C) 1995-1997, 2000-2003, 2004-2009 Free Software Foundation, Inc.
5 This file is part of GNU Bash.
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Bash is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
26 /* The LC_MESSAGES locale category is the category used by the functions
27 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
28 On systems that don't define it, use an arbitrary value instead.
29 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
30 then includes <libintl.h> (i.e. this file!) and then only defines
31 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
33 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
34 # define LC_MESSAGES 1729
37 /* We define an additional symbol to signal that we use the GNU
38 implementation of gettext. */
39 #define __USE_GNU_GETTEXT 1
41 /* Provide information about the supported file formats. Returns the
42 maximum minor revision number supported for a given major revision. */
43 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
44 ((major) == 0 ? 1 : -1)
46 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
47 precedence over _conio_gettext. */
52 /* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
53 used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
55 # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
56 # define _INTL_PARAMS(args) args
58 # define _INTL_PARAMS(args) ()
67 /* We redirect the functions to those prefixed with "libintl_". This is
68 necessary, because some systems define gettext/textdomain/... in the C
69 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
70 If we used the unprefixed names, there would be cases where the
71 definition in the C library would override the one in the libintl.so
72 shared library. Recall that on ELF systems, the symbols are looked
73 up in the following order:
75 2. in the shared libraries specified on the link command line, in order,
76 3. in the dependencies of the shared libraries specified on the link
78 4. in the dlopen()ed shared libraries, in the order in which they were
80 The definition in the C library would override the one in libintl.so if
82 * -lc is given on the link command line and -lintl isn't, or
83 * -lc is given on the link command line before -lintl, or
84 * libintl.so is a dependency of a dlopen()ed shared library but not
85 linked to the executable at link time.
86 Since Solaris gettext() behaves differently than GNU gettext(), this
87 would be unacceptable.
89 The redirection happens by default through macros in C, so that &gettext
90 is independent of the compilation unit, but through inline functions in
91 C++, in order not to interfere with the name mangling of class fields or
92 class methods called 'gettext'. */
94 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
95 If he doesn't, we choose the method. A third possible method is
96 _INTL_REDIRECT_ASM, supported only by GCC. */
97 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
98 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
99 # define _INTL_REDIRECT_ASM
102 # define _INTL_REDIRECT_INLINE
104 # define _INTL_REDIRECT_MACROS
108 /* Auxiliary macros. */
109 #ifdef _INTL_REDIRECT_ASM
110 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
111 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
112 # define _INTL_STRINGIFY(prefix) #prefix
114 # define _INTL_ASM(cname)
117 /* Look up MSGID in the current default message catalog for the current
118 LC_MESSAGES locale. If not found, returns MSGID itself (the default
120 #ifdef _INTL_REDIRECT_INLINE
121 extern char *libintl_gettext (const char *__msgid
);
122 static inline char *gettext (const char *__msgid
)
124 return libintl_gettext (__msgid
);
127 #ifdef _INTL_REDIRECT_MACROS
128 # define gettext libintl_gettext
130 extern char *gettext
_INTL_PARAMS ((const char *__msgid
))
131 _INTL_ASM (libintl_gettext
);
134 /* Look up MSGID in the DOMAINNAME message catalog for the current
135 LC_MESSAGES locale. */
136 #ifdef _INTL_REDIRECT_INLINE
137 extern char *libintl_dgettext (const char *__domainname
, const char *__msgid
);
138 static inline char *dgettext (const char *__domainname
, const char *__msgid
)
140 return libintl_dgettext (__domainname
, __msgid
);
143 #ifdef _INTL_REDIRECT_MACROS
144 # define dgettext libintl_dgettext
146 extern char *dgettext
_INTL_PARAMS ((const char *__domainname
,
147 const char *__msgid
))
148 _INTL_ASM (libintl_dgettext
);
151 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
153 #ifdef _INTL_REDIRECT_INLINE
154 extern char *libintl_dcgettext (const char *__domainname
, const char *__msgid
,
156 static inline char *dcgettext (const char *__domainname
, const char *__msgid
,
159 return libintl_dcgettext (__domainname
, __msgid
, __category
);
162 #ifdef _INTL_REDIRECT_MACROS
163 # define dcgettext libintl_dcgettext
165 extern char *dcgettext
_INTL_PARAMS ((const char *__domainname
,
168 _INTL_ASM (libintl_dcgettext
);
172 /* Similar to `gettext' but select the plural form corresponding to the
174 #ifdef _INTL_REDIRECT_INLINE
175 extern char *libintl_ngettext (const char *__msgid1
, const char *__msgid2
,
176 unsigned long int __n
);
177 static inline char *ngettext (const char *__msgid1
, const char *__msgid2
,
178 unsigned long int __n
)
180 return libintl_ngettext (__msgid1
, __msgid2
, __n
);
183 #ifdef _INTL_REDIRECT_MACROS
184 # define ngettext libintl_ngettext
186 extern char *ngettext
_INTL_PARAMS ((const char *__msgid1
,
187 const char *__msgid2
,
188 unsigned long int __n
))
189 _INTL_ASM (libintl_ngettext
);
192 /* Similar to `dgettext' but select the plural form corresponding to the
194 #ifdef _INTL_REDIRECT_INLINE
195 extern char *libintl_dngettext (const char *__domainname
, const char *__msgid1
,
196 const char *__msgid2
, unsigned long int __n
);
197 static inline char *dngettext (const char *__domainname
, const char *__msgid1
,
198 const char *__msgid2
, unsigned long int __n
)
200 return libintl_dngettext (__domainname
, __msgid1
, __msgid2
, __n
);
203 #ifdef _INTL_REDIRECT_MACROS
204 # define dngettext libintl_dngettext
206 extern char *dngettext
_INTL_PARAMS ((const char *__domainname
,
207 const char *__msgid1
,
208 const char *__msgid2
,
209 unsigned long int __n
))
210 _INTL_ASM (libintl_dngettext
);
213 /* Similar to `dcgettext' but select the plural form corresponding to the
215 #ifdef _INTL_REDIRECT_INLINE
216 extern char *libintl_dcngettext (const char *__domainname
,
217 const char *__msgid1
, const char *__msgid2
,
218 unsigned long int __n
, int __category
);
219 static inline char *dcngettext (const char *__domainname
,
220 const char *__msgid1
, const char *__msgid2
,
221 unsigned long int __n
, int __category
)
223 return libintl_dcngettext (__domainname
, __msgid1
, __msgid2
, __n
, __category
);
226 #ifdef _INTL_REDIRECT_MACROS
227 # define dcngettext libintl_dcngettext
229 extern char *dcngettext
_INTL_PARAMS ((const char *__domainname
,
230 const char *__msgid1
,
231 const char *__msgid2
,
232 unsigned long int __n
,
234 _INTL_ASM (libintl_dcngettext
);
238 /* Set the current default message catalog to DOMAINNAME.
239 If DOMAINNAME is null, return the current default.
240 If DOMAINNAME is "", reset to the default of "messages". */
241 #ifdef _INTL_REDIRECT_INLINE
242 extern char *libintl_textdomain (const char *__domainname
);
243 static inline char *textdomain (const char *__domainname
)
245 return libintl_textdomain (__domainname
);
248 #ifdef _INTL_REDIRECT_MACROS
249 # define textdomain libintl_textdomain
251 extern char *textdomain
_INTL_PARAMS ((const char *__domainname
))
252 _INTL_ASM (libintl_textdomain
);
255 /* Specify that the DOMAINNAME message catalog will be found
256 in DIRNAME rather than in the system locale data base. */
257 #ifdef _INTL_REDIRECT_INLINE
258 extern char *libintl_bindtextdomain (const char *__domainname
,
259 const char *__dirname
);
260 static inline char *bindtextdomain (const char *__domainname
,
261 const char *__dirname
)
263 return libintl_bindtextdomain (__domainname
, __dirname
);
266 #ifdef _INTL_REDIRECT_MACROS
267 # define bindtextdomain libintl_bindtextdomain
269 extern char *bindtextdomain
_INTL_PARAMS ((const char *__domainname
,
270 const char *__dirname
))
271 _INTL_ASM (libintl_bindtextdomain
);
274 /* Specify the character encoding in which the messages from the
275 DOMAINNAME message catalog will be returned. */
276 #ifdef _INTL_REDIRECT_INLINE
277 extern char *libintl_bind_textdomain_codeset (const char *__domainname
,
278 const char *__codeset
);
279 static inline char *bind_textdomain_codeset (const char *__domainname
,
280 const char *__codeset
)
282 return libintl_bind_textdomain_codeset (__domainname
, __codeset
);
285 #ifdef _INTL_REDIRECT_MACROS
286 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
288 extern char *bind_textdomain_codeset
_INTL_PARAMS ((const char *__domainname
,
289 const char *__codeset
))
290 _INTL_ASM (libintl_bind_textdomain_codeset
);
294 /* Support for relocatable packages. */
296 /* Sets the original and the current installation prefix of the package.
297 Relocation simply replaces a pathname starting with the original prefix
298 by the corresponding pathname with the current prefix instead. Both
299 prefixes should be directory names without trailing slash (i.e. use ""
301 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
303 libintl_set_relocation_prefix
_INTL_PARAMS ((const char *orig_prefix
,
304 const char *curr_prefix
));
311 #endif /* libintl.h */