home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gettext-0.10.24-bin.lha / include / libintl.h
C/C++ Source or Header  |  1996-10-12  |  4KB  |  111 lines

  1. /* libintl.h -- Message catalogs for internationalization.
  2. Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. 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
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  17.  
  18. #ifndef _LIBINTL_H
  19. #define _LIBINTL_H    1
  20.  
  21. #include <locale.h>
  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. #ifndef PARAMS
  28. # if __STDC__
  29. #  define PARAMS(args) args
  30. # else
  31. #  define PARAMS(args) ()
  32. # endif
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. /* Look up MSGID in the current default message catalog for the current
  40.    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
  41.    text).  */
  42. extern char *gettext PARAMS ((const char *__msgid));
  43.  
  44. /* Look up MSGID in the DOMAINNAME message catalog for the current
  45.    LC_MESSAGES locale.  */
  46. extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
  47.  
  48. /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
  49.    locale.  */
  50. extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
  51.                 int __category));
  52.  
  53.  
  54. /* Set the current default message catalog to DOMAINNAME.
  55.    If DOMAINNAME is null, return the current default.
  56.    If DOMAINNAME is "", reset to the default of "messages".  */
  57. extern char *textdomain PARAMS ((const char *__domainname));
  58.  
  59. /* Specify that the DOMAINNAME message catalog will be found
  60.    in DIRNAME rather than in the system locale data base.  */
  61. extern char *bindtextdomain PARAMS ((const char *__domainname,
  62.                      const char *__dirname));
  63.  
  64.  
  65. /* Optimized version of the functions above.  */
  66. #if defined __OPTIMIZED
  67. /* These must be a macro.  Inlined functions are useless because the
  68.    `__builtin_constant_p' predicate in dcgettext would always return
  69.    false.  */
  70.  
  71. # define gettext(msgid) dgettext ((char *) 0, msgid)
  72.  
  73. # define dgettext(domainname, msgid)                          \
  74.   dcgettext (domainname, msgid, LC_MESSAGES)
  75.  
  76. # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
  77. /* This global variable is defined in loadmsgcat.c.  We need a sign,
  78.    whether a new catalog was loaded, which can be associated with all
  79.    translations.  */
  80. extern int _nl_msg_cat_cntr;
  81.  
  82. #  define dcgettext(domainname, msgid, category)                  \
  83.   (__extension__                                  \
  84.    ({                                          \
  85.      char *__result;                                  \
  86.      if (__builtin_constant_p (msgid))                          \
  87.        {                                      \
  88.      static char *__translation__;                          \
  89.      static int __catalog_counter__;                      \
  90.      if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
  91.        {                                      \
  92.          __translation__ =                              \
  93.            (dcgettext) ((domainname), (msgid), (category));              \
  94.          __catalog_counter__ = _nl_msg_cat_cntr;                  \
  95.        }                                      \
  96.      __result = __translation__;                          \
  97.        }                                      \
  98.      else                                      \
  99.        __result = (dcgettext) ((domainname), (msgid), (category));          \
  100.      __result;                                      \
  101.     }))
  102. # endif
  103. #endif /* Optimizing. */
  104.  
  105.  
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109.  
  110. #endif /* libintl.h */
  111.