]> git.lyx.org Git - lyx.git/blob - intl/libgnuintl.h.cmake
es.po: fix two shortcut clashes (ported from branch)
[lyx.git] / intl / libgnuintl.h.cmake
1 /* Message catalogs for internationalization.
2    Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
3
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)
7    any later version.
8
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.
13
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17    USA.  */
18
19 #ifndef _LIBINTL_H
20 #define _LIBINTL_H      1
21
22 #include "config.h"
23
24 #include <locale.h>
25
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
32    in this case.  */
33 #if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
34 # define LC_MESSAGES 1729
35 #endif
36
37 /* We define an additional symbol to signal that we use the GNU
38    implementation of gettext.  */
39 #define __USE_GNU_GETTEXT 1
40
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)
45
46 /* Resolve a platform specific conflict on DJGPP.  GNU gettext takes
47    precedence over _conio_gettext.  */
48 #ifdef __DJGPP__
49 # undef gettext
50 #endif
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56
57 /* Version number: (major<<16) + (minor<<8) + subminor */
58 #define LIBINTL_VERSION 0x001000
59 extern int libintl_version;
60
61
62 /* We redirect the functions to those prefixed with "libintl_".  This is
63    necessary, because some systems define gettext/textdomain/... in the C
64    library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
65    If we used the unprefixed names, there would be cases where the
66    definition in the C library would override the one in the libintl.so
67    shared library.  Recall that on ELF systems, the symbols are looked
68    up in the following order:
69      1. in the executable,
70      2. in the shared libraries specified on the link command line, in order,
71      3. in the dependencies of the shared libraries specified on the link
72         command line,
73      4. in the dlopen()ed shared libraries, in the order in which they were
74         dlopen()ed.
75    The definition in the C library would override the one in libintl.so if
76    either
77      * -lc is given on the link command line and -lintl isn't, or
78      * -lc is given on the link command line before -lintl, or
79      * libintl.so is a dependency of a dlopen()ed shared library but not
80        linked to the executable at link time.
81    Since Solaris gettext() behaves differently than GNU gettext(), this
82    would be unacceptable.
83
84    The redirection happens by default through macros in C, so that &gettext
85    is independent of the compilation unit, but through inline functions in
86    C++, in order not to interfere with the name mangling of class fields or
87    class methods called 'gettext'.  */
88
89 /* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
90    If he doesn't, we choose the method.  A third possible method is
91    _INTL_REDIRECT_ASM, supported only by GCC.  */
92 #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
93 # if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
94 #  define _INTL_REDIRECT_ASM
95 # else
96 #  ifdef __cplusplus
97 #   define _INTL_REDIRECT_INLINE
98 #  else
99 #   define _INTL_REDIRECT_MACROS
100 #  endif
101 # endif
102 #endif
103 /* Auxiliary macros.  */
104 #ifdef _INTL_REDIRECT_ASM
105 # define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
106 # define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
107 # define _INTL_STRINGIFY(prefix) #prefix
108 #else
109 # define _INTL_ASM(cname)
110 #endif
111
112 /* Look up MSGID in the current default message catalog for the current
113    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
114    text).  */
115 #ifdef _INTL_REDIRECT_INLINE
116 extern char *libintl_gettext (const char *__msgid);
117 static inline char *gettext (const char *__msgid)
118 {
119   return libintl_gettext (__msgid);
120 }
121 #else
122 #ifdef _INTL_REDIRECT_MACROS
123 # define gettext libintl_gettext
124 #endif
125 extern char *gettext (const char *__msgid)
126        _INTL_ASM (libintl_gettext);
127 #endif
128
129 /* Look up MSGID in the DOMAINNAME message catalog for the current
130    LC_MESSAGES locale.  */
131 #ifdef _INTL_REDIRECT_INLINE
132 extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
133 static inline char *dgettext (const char *__domainname, const char *__msgid)
134 {
135   return libintl_dgettext (__domainname, __msgid);
136 }
137 #else
138 #ifdef _INTL_REDIRECT_MACROS
139 # define dgettext libintl_dgettext
140 #endif
141 extern char *dgettext (const char *__domainname, const char *__msgid)
142        _INTL_ASM (libintl_dgettext);
143 #endif
144
145 /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
146    locale.  */
147 #ifdef _INTL_REDIRECT_INLINE
148 extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
149                                 int __category);
150 static inline char *dcgettext (const char *__domainname, const char *__msgid,
151                                int __category)
152 {
153   return libintl_dcgettext (__domainname, __msgid, __category);
154 }
155 #else
156 #ifdef _INTL_REDIRECT_MACROS
157 # define dcgettext libintl_dcgettext
158 #endif
159 extern char *dcgettext (const char *__domainname, const char *__msgid,
160                         int __category)
161        _INTL_ASM (libintl_dcgettext);
162 #endif
163
164
165 /* Similar to `gettext' but select the plural form corresponding to the
166    number N.  */
167 #ifdef _INTL_REDIRECT_INLINE
168 extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
169                                unsigned long int __n);
170 static inline char *ngettext (const char *__msgid1, const char *__msgid2,
171                               unsigned long int __n)
172 {
173   return libintl_ngettext (__msgid1, __msgid2, __n);
174 }
175 #else
176 #ifdef _INTL_REDIRECT_MACROS
177 # define ngettext libintl_ngettext
178 #endif
179 extern char *ngettext (const char *__msgid1, const char *__msgid2,
180                        unsigned long int __n)
181        _INTL_ASM (libintl_ngettext);
182 #endif
183
184 /* Similar to `dgettext' but select the plural form corresponding to the
185    number N.  */
186 #ifdef _INTL_REDIRECT_INLINE
187 extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
188                                 const char *__msgid2, unsigned long int __n);
189 static inline char *dngettext (const char *__domainname, const char *__msgid1,
190                                const char *__msgid2, unsigned long int __n)
191 {
192   return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
193 }
194 #else
195 #ifdef _INTL_REDIRECT_MACROS
196 # define dngettext libintl_dngettext
197 #endif
198 extern char *dngettext (const char *__domainname,
199                         const char *__msgid1, const char *__msgid2,
200                         unsigned long int __n)
201        _INTL_ASM (libintl_dngettext);
202 #endif
203
204 /* Similar to `dcgettext' but select the plural form corresponding to the
205    number N.  */
206 #ifdef _INTL_REDIRECT_INLINE
207 extern char *libintl_dcngettext (const char *__domainname,
208                                  const char *__msgid1, const char *__msgid2,
209                                  unsigned long int __n, int __category);
210 static inline char *dcngettext (const char *__domainname,
211                                 const char *__msgid1, const char *__msgid2,
212                                 unsigned long int __n, int __category)
213 {
214   return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
215 }
216 #else
217 #ifdef _INTL_REDIRECT_MACROS
218 # define dcngettext libintl_dcngettext
219 #endif
220 extern char *dcngettext (const char *__domainname,
221                          const char *__msgid1, const char *__msgid2,
222                          unsigned long int __n, int __category)
223        _INTL_ASM (libintl_dcngettext);
224 #endif
225
226
227 #ifndef IN_LIBGLOCALE
228
229 /* Set the current default message catalog to DOMAINNAME.
230    If DOMAINNAME is null, return the current default.
231    If DOMAINNAME is "", reset to the default of "messages".  */
232 #ifdef _INTL_REDIRECT_INLINE
233 extern char *libintl_textdomain (const char *__domainname);
234 static inline char *textdomain (const char *__domainname)
235 {
236   return libintl_textdomain (__domainname);
237 }
238 #else
239 #ifdef _INTL_REDIRECT_MACROS
240 # define textdomain libintl_textdomain
241 #endif
242 extern char *textdomain (const char *__domainname)
243        _INTL_ASM (libintl_textdomain);
244 #endif
245
246 /* Specify that the DOMAINNAME message catalog will be found
247    in DIRNAME rather than in the system locale data base.  */
248 #ifdef _INTL_REDIRECT_INLINE
249 extern char *libintl_bindtextdomain (const char *__domainname,
250                                      const char *__dirname);
251 static inline char *bindtextdomain (const char *__domainname,
252                                     const char *__dirname)
253 {
254   return libintl_bindtextdomain (__domainname, __dirname);
255 }
256 #else
257 #ifdef _INTL_REDIRECT_MACROS
258 # define bindtextdomain libintl_bindtextdomain
259 #endif
260 extern char *bindtextdomain (const char *__domainname, const char *__dirname)
261        _INTL_ASM (libintl_bindtextdomain);
262 #endif
263
264 /* Specify the character encoding in which the messages from the
265    DOMAINNAME message catalog will be returned.  */
266 #ifdef _INTL_REDIRECT_INLINE
267 extern char *libintl_bind_textdomain_codeset (const char *__domainname,
268                                               const char *__codeset);
269 static inline char *bind_textdomain_codeset (const char *__domainname,
270                                              const char *__codeset)
271 {
272   return libintl_bind_textdomain_codeset (__domainname, __codeset);
273 }
274 #else
275 #ifdef _INTL_REDIRECT_MACROS
276 # define bind_textdomain_codeset libintl_bind_textdomain_codeset
277 #endif
278 extern char *bind_textdomain_codeset (const char *__domainname,
279                                       const char *__codeset)
280        _INTL_ASM (libintl_bind_textdomain_codeset);
281 #endif
282
283 #endif /* IN_LIBGLOCALE */
284
285
286 /* Support for format strings with positions in *printf(), following the
287    POSIX/XSI specification.
288    Note: These replacements for the *printf() functions are visible only
289    in source files that #include <libintl.h> or #include "gettext.h".
290    Packages that use *printf() in source files that don't refer to _()
291    or gettext() but for which the format string could be the return value
292    of _() or gettext() need to add this #include.  Oh well.  */
293
294 #if !HAVE_POSIX_PRINTF
295
296 #include <stdio.h>
297 #include <stddef.h>
298
299 /* Get va_list.  */
300 #if __STDC__ || defined __cplusplus || defined _MSC_VER
301 # include <stdarg.h>
302 #else
303 # include <varargs.h>
304 #endif
305
306 #undef fprintf
307 #define fprintf libintl_fprintf
308 extern int fprintf (FILE *, const char *, ...);
309 #undef vfprintf
310 #define vfprintf libintl_vfprintf
311 extern int vfprintf (FILE *, const char *, va_list);
312
313 #undef printf
314 #if defined __NetBSD__ || defined __CYGWIN__ || defined __MINGW32__
315 /* Don't break __attribute__((format(printf,M,N))).
316    This redefinition is only possible because the libc in NetBSD, Cygwin,
317    mingw does not have a function __printf__.  */
318 # define libintl_printf __printf__
319 #endif
320 #define printf libintl_printf
321 extern int printf (const char *, ...);
322 #undef vprintf
323 #define vprintf libintl_vprintf
324 extern int vprintf (const char *, va_list);
325
326 #undef sprintf
327 #define sprintf libintl_sprintf
328 extern int sprintf (char *, const char *, ...);
329 #undef vsprintf
330 #define vsprintf libintl_vsprintf
331 extern int vsprintf (char *, const char *, va_list);
332
333 #if HAVE_SNPRINTF
334
335 #undef snprintf
336 #define snprintf libintl_snprintf
337 extern int snprintf (char *, size_t, const char *, ...);
338 #undef vsnprintf
339 #define vsnprintf libintl_vsnprintf
340 extern int vsnprintf (char *, size_t, const char *, va_list);
341
342 #endif
343
344 #if HAVE_ASPRINTF
345
346 #undef asprintf
347 #define asprintf libintl_asprintf
348 extern int asprintf (char **, const char *, ...);
349 #undef vasprintf
350 #define vasprintf libintl_vasprintf
351 extern int vasprintf (char **, const char *, va_list);
352
353 #endif
354
355 #if HAVE_WPRINTF
356
357 #undef fwprintf
358 #define fwprintf libintl_fwprintf
359 extern int fwprintf (FILE *, const wchar_t *, ...);
360 #undef vfwprintf
361 #define vfwprintf libintl_vfwprintf
362 extern int vfwprintf (FILE *, const wchar_t *, va_list);
363
364 #undef wprintf
365 #define wprintf libintl_wprintf
366 extern int wprintf (const wchar_t *, ...);
367 #undef vwprintf
368 #define vwprintf libintl_vwprintf
369 extern int vwprintf (const wchar_t *, va_list);
370
371 #undef swprintf
372 #define swprintf libintl_swprintf
373 extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
374 #undef vswprintf
375 #define vswprintf libintl_vswprintf
376 extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
377
378 #endif
379
380 #endif
381
382
383 /* Support for relocatable packages.  */
384
385 /* Sets the original and the current installation prefix of the package.
386    Relocation simply replaces a pathname starting with the original prefix
387    by the corresponding pathname with the current prefix instead.  Both
388    prefixes should be directory names without trailing slash (i.e. use ""
389    instead of "/").  */
390 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
391 extern void
392        libintl_set_relocation_prefix (const char *orig_prefix,
393                                       const char *curr_prefix);
394
395
396 #ifdef __cplusplus
397 }
398 #endif
399     
400 #endif /* libintl.h */