1 /* Message catalogs for internationalization.
2 Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published
6 by the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 /* The LC_MESSAGES locale category is the category used by the functions
25 gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
26 On systems that don't define it, use an arbitrary value instead.
27 On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
28 then includes <libintl.h> (i.e. this file!) and then only defines
29 LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
31 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
32 # define LC_MESSAGES 1729
35 /* We define an additional symbol to signal that we use the GNU
36 implementation of gettext. */
37 #define __USE_GNU_GETTEXT 1
39 /* Provide information about the supported file formats. Returns the
40 maximum minor revision number supported for a given major revision. */
41 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
42 ((major) == 0 ? 1 : -1)
44 /* Resolve a platform specific conflict on DJGPP. GNU gettext takes
45 precedence over _conio_gettext. */
55 /* We redirect the functions to those prefixed with "libintl_". This is
56 necessary, because some systems define gettext/textdomain/... in the C
57 library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
58 If we used the unprefixed names, there would be cases where the
59 definition in the C library would override the one in the libintl.so
60 shared library. Recall that on ELF systems, the symbols are looked
61 up in the following order:
63 2. in the shared libraries specified on the link command line, in order,
64 3. in the dependencies of the shared libraries specified on the link
66 4. in the dlopen()ed shared libraries, in the order in which they were
68 The definition in the C library would override the one in libintl.so if
70 * -lc is given on the link command line and -lintl isn't, or
71 * -lc is given on the link command line before -lintl, or
72 * libintl.so is a dependency of a dlopen()ed shared library but not
73 linked to the executable at link time.
74 Since Solaris gettext() behaves differently than GNU gettext(), this
75 would be unacceptable.
77 The redirection happens by default through macros in C, so that &gettext
78 is independent of the compilation unit, but through inline functions in
79 C++, in order not to interfere with the name mangling of class fields or
80 class methods called 'gettext'. */
82 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
83 If he doesn't, we choose the method. A third possible method is
84 _INTL_REDIRECT_ASM, supported only by GCC. */
85 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
86 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
87 # define _INTL_REDIRECT_ASM
90 # define _INTL_REDIRECT_INLINE
92 # define _INTL_REDIRECT_MACROS
96 /* Auxiliary macros. */
97 #ifdef _INTL_REDIRECT_ASM
98 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
99 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
100 # define _INTL_STRINGIFY(prefix) #prefix
102 # define _INTL_ASM(cname)
105 /* Look up MSGID in the current default message catalog for the current
106 LC_MESSAGES locale. If not found, returns MSGID itself (the default
108 #ifdef _INTL_REDIRECT_INLINE
109 extern char *libintl_gettext (const char *__msgid
);
110 static inline char *gettext (const char *__msgid
)
112 return libintl_gettext (__msgid
);
115 #ifdef _INTL_REDIRECT_MACROS
116 # define gettext libintl_gettext
118 extern char *gettext (const char *__msgid
)
119 _INTL_ASM (libintl_gettext
);
122 /* Look up MSGID in the DOMAINNAME message catalog for the current
123 LC_MESSAGES locale. */
124 #ifdef _INTL_REDIRECT_INLINE
125 extern char *libintl_dgettext (const char *__domainname
, const char *__msgid
);
126 static inline char *dgettext (const char *__domainname
, const char *__msgid
)
128 return libintl_dgettext (__domainname
, __msgid
);
131 #ifdef _INTL_REDIRECT_MACROS
132 # define dgettext libintl_dgettext
134 extern char *dgettext (const char *__domainname
, const char *__msgid
)
135 _INTL_ASM (libintl_dgettext
);
138 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
140 #ifdef _INTL_REDIRECT_INLINE
141 extern char *libintl_dcgettext (const char *__domainname
, const char *__msgid
,
143 static inline char *dcgettext (const char *__domainname
, const char *__msgid
,
146 return libintl_dcgettext (__domainname
, __msgid
, __category
);
149 #ifdef _INTL_REDIRECT_MACROS
150 # define dcgettext libintl_dcgettext
152 extern char *dcgettext (const char *__domainname
, const char *__msgid
,
154 _INTL_ASM (libintl_dcgettext
);
158 /* Similar to `gettext' but select the plural form corresponding to the
160 #ifdef _INTL_REDIRECT_INLINE
161 extern char *libintl_ngettext (const char *__msgid1
, const char *__msgid2
,
162 unsigned long int __n
);
163 static inline char *ngettext (const char *__msgid1
, const char *__msgid2
,
164 unsigned long int __n
)
166 return libintl_ngettext (__msgid1
, __msgid2
, __n
);
169 #ifdef _INTL_REDIRECT_MACROS
170 # define ngettext libintl_ngettext
172 extern char *ngettext (const char *__msgid1
, const char *__msgid2
,
173 unsigned long int __n
)
174 _INTL_ASM (libintl_ngettext
);
177 /* Similar to `dgettext' but select the plural form corresponding to the
179 #ifdef _INTL_REDIRECT_INLINE
180 extern char *libintl_dngettext (const char *__domainname
, const char *__msgid1
,
181 const char *__msgid2
, unsigned long int __n
);
182 static inline char *dngettext (const char *__domainname
, const char *__msgid1
,
183 const char *__msgid2
, unsigned long int __n
)
185 return libintl_dngettext (__domainname
, __msgid1
, __msgid2
, __n
);
188 #ifdef _INTL_REDIRECT_MACROS
189 # define dngettext libintl_dngettext
191 extern char *dngettext (const char *__domainname
,
192 const char *__msgid1
, const char *__msgid2
,
193 unsigned long int __n
)
194 _INTL_ASM (libintl_dngettext
);
197 /* Similar to `dcgettext' but select the plural form corresponding to the
199 #ifdef _INTL_REDIRECT_INLINE
200 extern char *libintl_dcngettext (const char *__domainname
,
201 const char *__msgid1
, const char *__msgid2
,
202 unsigned long int __n
, int __category
);
203 static inline char *dcngettext (const char *__domainname
,
204 const char *__msgid1
, const char *__msgid2
,
205 unsigned long int __n
, int __category
)
207 return libintl_dcngettext (__domainname
, __msgid1
, __msgid2
, __n
, __category
);
210 #ifdef _INTL_REDIRECT_MACROS
211 # define dcngettext libintl_dcngettext
213 extern char *dcngettext (const char *__domainname
,
214 const char *__msgid1
, const char *__msgid2
,
215 unsigned long int __n
, int __category
)
216 _INTL_ASM (libintl_dcngettext
);
220 /* Set the current default message catalog to DOMAINNAME.
221 If DOMAINNAME is null, return the current default.
222 If DOMAINNAME is "", reset to the default of "messages". */
223 #ifdef _INTL_REDIRECT_INLINE
224 extern char *libintl_textdomain (const char *__domainname
);
225 static inline char *textdomain (const char *__domainname
)
227 return libintl_textdomain (__domainname
);
230 #ifdef _INTL_REDIRECT_MACROS
231 # define textdomain libintl_textdomain
233 extern char *textdomain (const char *__domainname
)
234 _INTL_ASM (libintl_textdomain
);
237 /* Specify that the DOMAINNAME message catalog will be found
238 in DIRNAME rather than in the system locale data base. */
239 #ifdef _INTL_REDIRECT_INLINE
240 extern char *libintl_bindtextdomain (const char *__domainname
,
241 const char *__dirname
);
242 static inline char *bindtextdomain (const char *__domainname
,
243 const char *__dirname
)
245 return libintl_bindtextdomain (__domainname
, __dirname
);
248 #ifdef _INTL_REDIRECT_MACROS
249 # define bindtextdomain libintl_bindtextdomain
251 extern char *bindtextdomain (const char *__domainname
, const char *__dirname
)
252 _INTL_ASM (libintl_bindtextdomain
);
255 /* Specify the character encoding in which the messages from the
256 DOMAINNAME message catalog will be returned. */
257 #ifdef _INTL_REDIRECT_INLINE
258 extern char *libintl_bind_textdomain_codeset (const char *__domainname
,
259 const char *__codeset
);
260 static inline char *bind_textdomain_codeset (const char *__domainname
,
261 const char *__codeset
)
263 return libintl_bind_textdomain_codeset (__domainname
, __codeset
);
266 #ifdef _INTL_REDIRECT_MACROS
267 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
269 extern char *bind_textdomain_codeset (const char *__domainname
,
270 const char *__codeset
)
271 _INTL_ASM (libintl_bind_textdomain_codeset
);
275 /* Support for format strings with positions in *printf(), following the
276 POSIX/XSI specification.
277 Note: These replacements for the *printf() functions are visible only
278 in source files that #include <libintl.h> or #include "gettext.h".
279 Packages that use *printf() in source files that don't refer to _()
280 or gettext() but for which the format string could be the return value
281 of _() or gettext() need to add this #include. Oh well. */
283 #if !@HAVE_POSIX_PRINTF@
289 #if __STDC__ || defined __cplusplus || defined _MSC_VER
292 # include <varargs.h>
296 #define fprintf libintl_fprintf
297 extern int fprintf (FILE *, const char *, ...);
299 #define vfprintf libintl_vfprintf
300 extern int vfprintf (FILE *, const char *, va_list);
303 #define printf libintl_printf
304 extern int printf (const char *, ...);
306 #define vprintf libintl_vprintf
307 extern int vprintf (const char *, va_list);
310 #define sprintf libintl_sprintf
311 extern int sprintf (char *, const char *, ...);
313 #define vsprintf libintl_vsprintf
314 extern int vsprintf (char *, const char *, va_list);
319 #define snprintf libintl_snprintf
320 extern int snprintf (char *, size_t, const char *, ...);
322 #define vsnprintf libintl_vsnprintf
323 extern int vsnprintf (char *, size_t, const char *, va_list);
330 #define asprintf libintl_asprintf
331 extern int asprintf (char **, const char *, ...);
333 #define vasprintf libintl_vasprintf
334 extern int vasprintf (char **, const char *, va_list);
341 #define fwprintf libintl_fwprintf
342 extern int fwprintf (FILE *, const wchar_t *, ...);
344 #define vfwprintf libintl_vfwprintf
345 extern int vfwprintf (FILE *, const wchar_t *, va_list);
348 #define wprintf libintl_wprintf
349 extern int wprintf (const wchar_t *, ...);
351 #define vwprintf libintl_vwprintf
352 extern int vwprintf (const wchar_t *, va_list);
355 #define swprintf libintl_swprintf
356 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
358 #define vswprintf libintl_vswprintf
359 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
366 /* Support for relocatable packages. */
368 /* Sets the original and the current installation prefix of the package.
369 Relocation simply replaces a pathname starting with the original prefix
370 by the corresponding pathname with the current prefix instead. Both
371 prefixes should be directory names without trailing slash (i.e. use ""
373 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
375 libintl_set_relocation_prefix (const char *orig_prefix
,
376 const char *curr_prefix
);
383 #endif /* libintl.h */